Skip to content

Commit 7c1ffd7

Browse files
committed
Merge branch 'main' into do_not_merge_anahita_secret_customer_onboarding_page
2 parents 487a8e6 + abe76ea commit 7c1ffd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1467
-717
lines changed

.github/workflows/check-links.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Check links
2+
3+
on: pull_request
4+
5+
jobs:
6+
check-links:
7+
name: Check links
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Set up Node
12+
uses: actions/setup-node@v4
13+
with:
14+
node-version: "latest"
15+
- name: Install Mintlify CLI
16+
run: npm i -g mintlify
17+
- name: Run broken link checker
18+
run: mintlify broken-links

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
node_modules
3+
package-lock.json

advanced/custom/css.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: 'Fully customize your documentation with custom CSS'
44
---
55

66
<Check>
7-
Custom CSS is available on the [growth plan](https://mintlify.com/pricing).
7+
Custom CSS is available as an add-on to the [pro plan](https://mintlify.com/pricing).
88
</Check>
99

1010
Add any number of CSS files to your repository and the defined class names will be applied and available across all of your MDX files.

advanced/custom/js.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ description: 'Add JavaScript functionality globally'
44
---
55

66
<Check>
7-
Custom JS is available on the [growth plan](https://mintlify.com/pricing).
7+
Custom JS is available as an add-on to the [pro plan](https://mintlify.com/pricing).
88
</Check>
99

1010
Custom JS allows you to add custom executable code globally. It is the equivalent of adding a `<script>` tag with JS code into every page.
1111

12-
## Adding script.js
12+
## Adding Custom JavaScript
1313

14-
For example, you can add the following `script.js` file to enable [Google Analytics](https://marketingplatform.google.com/about/analytics) across the entire documentation.
14+
Any `.js` file inside the content directory of your docs will be included in every documentation page. For example, you can add the following `ga.js` file to enable [Google Analytics](https://marketingplatform.google.com/about/analytics) across the entire documentation.
1515

1616
```js
1717
window.dataLayer = window.dataLayer || [];

advanced/rest-api/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ functionality to the API overtime. Let us know what else you want to see in
1414
## Authentication
1515

1616
You can generate an API key through
17-
[the dashboard](https://dashboard.mintlify.com/settings/api). The API key is
17+
[the dashboard](https://dashboard.mintlify.com/settings/integrations). The API key is
1818
associated with the entire org and can be used across multiple deployments.
1919

2020
<Frame>

advanced/subpath/cloudflare.mdx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Host documentation at a /docs subpath using Cloudflare Workers"
55

66
import SubpathGatingSnippet from "/snippets/custom-subpath-gating.mdx";
77

8-
<SubpathGatingSnippet />
8+
<SubpathGatingSnippet platform="Cloudflare" />
99

1010
## Create Cloudflare Worker
1111

@@ -21,7 +21,7 @@ Cloudlfare worker.
2121

2222
Once the worker is created, click `Configure worker`. Navigate to the worker
2323
`Settings > Triggers`. Click on `Add Custom Domain` to add your desired domain
24-
into the list - we reccommend you add both the version with and without `www.`
24+
into the list - we recommend you add both the version with and without `www.`
2525
prepended to the domain.
2626

2727
<Frame>
@@ -77,16 +77,8 @@ async function handleRequest(request) {
7777
// if no action found, play the regular request
7878
return await fetch(request);
7979
}
80-
81-
return await fetch(request);
8280
}
8381
```
8482

8583
Click on `Deploy` and wait for the changes to propagate (it can take up to a few
8684
hours).
87-
88-
## Reach out to Mintlify team
89-
90-
Once completing the Cloudflare setup, the Mintlify team will setup the
91-
subdirectory settings in your deployment. Reach out over
92-
[email](mailto:[email protected]).

advanced/subpath/route53-cloudfront.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Host documentation at a /docs subdirectory using AWS services"
55

66
import SubpathGatingSnippet from "/snippets/custom-subpath-gating.mdx";
77

8-
<SubpathGatingSnippet />
8+
<SubpathGatingSnippet platform="AWS Services" />
99

1010
## Create Cloudfront Distribution
1111

advanced/subpath/vercel.mdx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "Vercel"
3+
description: "Host documentation at a /docs subpath using Vercel"
4+
---
5+
6+
import SubpathGatingSnippet from "/snippets/custom-subpath-gating.mdx";
7+
8+
<SubpathGatingSnippet platform="Vercel" />
9+
10+
## vercel.json Configuration
11+
12+
To host your documentation at a custom subpath using Vercel, you need to add the
13+
following configuration to your `vercel.json` file.
14+
15+
```json
16+
{
17+
"rewrites": [
18+
{
19+
"source": "/docs",
20+
"destination": "https://[subdomain].mintlify.dev/docs"
21+
},
22+
{
23+
"source": "/docs/:match*",
24+
"destination": "https://[subdomain].mintlify.dev/docs/:match*"
25+
}
26+
]
27+
}
28+
```
29+
30+
<Note>
31+
For more information, you can also refer to Vercel's offical guide on check
32+
out the [Project Configuration:
33+
Rewrites](https://vercel.com/docs/projects/project-configuration#rewrites)
34+
</Note>

advanced/user-auth/choosing-an-auth-method.mdx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Before your users can access personalized content, they must be authenticated. M
77

88
1. **Shared Session**: Utilize the same session token used by your dashboard to authenticate users.
99
2. **JWT**: Use your own login flow to send user info to your docs via a JWT in the URL.
10+
3. **OAuth 2.0**: Integrate with your OAuth server to enable user login via the PKCE flow.
1011

1112
## Prerequisites
1213

@@ -23,10 +24,15 @@ Before your users can access personalized content, they must be authenticated. M
2324
- If your dashboard is at `*.foo.com`, your **docs** must be hosted at `foo.com` or `*.foo.com`
2425
</Tab>
2526
<Tab title="JWT">
26-
27+
2728
- You have some existing login flow.
2829
- You can add a final step in this login flow that creates a JWT and redirects to the docs.
2930
</Tab>
31+
<Tab title="OAuth 2.0">
32+
33+
- You have an existing OAuth server that supports the PKCE flow.
34+
- You can create a new API endpoint that can be accessed by the returned OAuth access token.
35+
</Tab>
3036
</Tabs>
3137

3238
## Pros & Cons
@@ -42,20 +48,34 @@ Before your users can access personalized content, they must be authenticated. M
4248
Cons:
4349

4450
- Your docs will make a request to your backend, which may be undesirable
51+
- You must have a dashboard that uses session authentication
52+
- CORS configuration is usually required
4553
</Tab>
4654
<Tab title="JWT">
4755
Pros:
4856

49-
- No dashboard needed
5057
- Reduced risk of API endpoint abuse
5158
- Zero CORS configuration
59+
- No restrictions on API URLs
5260

5361
Cons:
5462

55-
- Must build new functionality around your existing login flow
63+
- Must be able to hook into your existing login flow
5664
- Dashboard sessions and docs authentication are completely decoupled, so users will need to log in to your dashboard and your docs separately
5765
- Every time you want to refresh user data, your users must re-login to your docs
5866
- If your users' data changes frequently, you must require your users to log in frequently or risk having stale data in the docs
5967
- If your users' data rarely changes, this shouldn't be a problem
6068
</Tab>
69+
<Tab title="OAuth 2.0">
70+
Pros:
71+
72+
- Heightened security standard
73+
- No restrictions on API URLs
74+
75+
Cons:
76+
77+
- Requires significant work if setting up OAuth server for the first time
78+
- Dashboard sessions and docs authentication are completely decoupled, so users will need to log in to your dashboard and your docs separately
79+
- Might be overkill for some applications
80+
</Tab>
6181
</Tabs>

advanced/user-auth/jwt.mdx

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,70 @@ If you don’t have a dashboard, or if you want to keep your dashboard and docs
99

1010
<Steps>
1111
<Step title="Generate a private key">
12-
Go to your [Mintlify dashboard settings](https://dashboard.mintlify.com/settings/integrations) and generate a private key. Store this key somewhere secure where it can be accessed by your backend.
12+
Go to your [Mintlify dashboard settings](https://dashboard.mintlify.com/mintlify/mintlify/settings/deployment/user-authentication) and generate a private key. Store this key somewhere secure where it can be accessed by your backend.
1313
</Step>
1414
<Step title="Create a login flow">
1515
Create a login flow that does the following:
1616
- Authenticate the user
1717
- Create a JWT containing the authenticated user's info in the [UserInfo](./sending-data) format
18-
- Sign the JWT with the secret
18+
- Sign the JWT with the secret, using the ES256 algorithm
1919
- Create a redirect URL back to your docs, including the JWT as the hash
2020
</Step>
2121
<Step title="Configure your User Auth settings">
22-
Return to your [Mintlify dashboard settings](https://dashboard.mintlify.com/settings/integrations) and add the login URL to your User Auth settings.
22+
Return to your [Mintlify dashboard settings](https://dashboard.mintlify.com/mintlify/mintlify/settings/deployment/user-authentication) and add the login URL to your User Auth settings.
2323
</Step>
2424
</Steps>
2525

2626
## Example
2727

28-
I want to set up authentication for my docs hosted at `docs.foo.com`. I want my docs to be completely separate from my dashboard (or I don’t have a dashboard at all).
28+
I want to set up authentication for my docs hosted at `docs.foo.com`. I want my docs
29+
to be completely separate from my dashboard (or I don’t have a dashboard at all).
2930

30-
To set up authentication with Mintlify, I go to my Mintlify dashboard and generate a JWT secret. I create a web URL `https://foo.com/docs-login` that initiates a login flow for my users. At the end of this login flow, once I have verified the identity of the user, I create a JWT containing the user’s custom data according to Mintlify’s specification. I sign this JWT with my Mintlify secret, create a redirect URL of the form `https://docs.foo.com#{SIGNED_JWT}`, and redirect the user.
31+
To set up authentication with Mintlify, I go to my Mintlify dashboard and generate a
32+
JWT secret. I create a web URL `https://foo.com/docs-login` that initiates a login flow
33+
for my users. At the end of this login flow, once I have verified the identity of the user,
34+
I create a JWT containing the user’s custom data according to Mintlify’s specification.
35+
I use a JWT library to sign this JWT with my Mintlify secret, create a redirect URL of the
36+
form `https://docs.foo.com#{SIGNED_JWT}`, and redirect the user.
3137

32-
I then go to the Mintlify dashboard settings and enter `https://foo.com/docs-login` for the Login URL field.
38+
I then go to the Mintlify dashboard settings and enter `https://foo.com/docs-login` for the
39+
Login URL field.
40+
41+
Here's what the code might look like:
42+
43+
```ts
44+
import * as jose from 'jose';
45+
import { Request, Response } from 'express';
46+
47+
const TWO_WEEKS_IN_MS = 1000 * 60 * 60 * 24 * 7 * 2;
48+
49+
const signingKey = await jose.importPKCS8(process.env.MINTLIFY_PRIVATE_KEY, 'ES256');
50+
51+
export async function handleRequest(req: Request, res: Response) {
52+
const userInfo = {
53+
expiresAt: Math.floor((Date.now() + TWO_WEEKS_IN_MS) / 1000),
54+
groups: res.locals.user.groups,
55+
content: {
56+
firstName: res.locals.user.firstName,
57+
lastName: res.locals.user.lastName,
58+
},
59+
};
60+
61+
const jwt = await new jose.SignJWT(userInfo)
62+
.setProtectedHeader({ alg: 'ES256' })
63+
.setExpirationTime('10 s')
64+
.sign(signingKey);
65+
66+
return res.redirect(`https://docs.foo.com#${jwt}`);
67+
}
68+
69+
```
70+
71+
## Preserving Anchors
72+
73+
Post-login, if you'd like to redirect to a specific anchor on the page, you can use the following format to create the redirect URL: `https://docs.foo.com/page#jwt={SIGNED_JWT}&anchor={ANCHOR}`.
74+
75+
Example:
76+
77+
- Original: `https://docs.foo.com/quickstart#step-one`
78+
- Redirect: `https://docs.foo.com/quickstart#jwt={SIGNED_JWT}&anchor=step-one`

0 commit comments

Comments
 (0)