Skip to content

Commit 620b556

Browse files
committed
undo format
1 parent d0a2b38 commit 620b556

File tree

1 file changed

+58
-73
lines changed

1 file changed

+58
-73
lines changed

authentication-personalization/authentication-setup.mdx

Lines changed: 58 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
title: "Authentication setup"
33
description: "Guarantee privacy of your docs by authenticating users"
44
icon: "file-lock"
5-
keywords: ["auth"]
5+
keywords: ['auth']
66
---
7-
87
Authentication requires users to log in before accessing your documentation. This guide covers setup for each available handshake method.
98

109
**Need help choosing?** See the [overview](/authentication-personalization/overview) to compare options.
1110

1211
<Info>
13-
Authentication methods are available on [Growth and Enterprise
14-
plans](https://mintlify.com/pricing?ref=authentication).
12+
Authentication methods are available on [Growth and Enterprise plans](https://mintlify.com/pricing?ref=authentication).
1513
</Info>
1614

1715
## Configuring authentication
@@ -22,28 +20,26 @@ Select the handshake method that you want to configure.
2220
<Tab title="JWT">
2321
### Prerequisites
2422

25-
- An authentication system that can generate and sign JWTs.
26-
- A backend service that can create redirect URLs.
23+
* An authentication system that can generate and sign JWTs.
24+
* A backend service that can create redirect URLs.
2725

2826
### Implementation
2927

3028
<Steps>
3129
<Step title="Generate a private key.">
32-
1. In your dashboard, go to
33-
[Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
34-
2. Select **Full Authentication** or **Partial Authentication**. 3. Select
35-
**JWT**. 4. Enter the URL of your existing login flow and select **Save
36-
changes**. 5. Select **Generate new key**. 6. Store your key securely where
37-
it can be accessed by your backend.
30+
1. In your dashboard, go to [Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
31+
2. Select **Full Authentication** or **Partial Authentication**.
32+
3. Select **JWT**.
33+
4. Enter the URL of your existing login flow and select **Save changes**.
34+
5. Select **Generate new key**.
35+
6. Store your key securely where it can be accessed by your backend.
3836
</Step>
3937
<Step title="Integrate Mintlify authentication into your login flow.">
40-
Modify your existing login flow to include these steps after user
41-
authentication: * Create a JWT containing the authenticated user's info in
42-
the `User` format. See [Sending
43-
Data](/authentication-personalization/sending-data) for more information. *
44-
Sign the JWT with your secret key, using the EdDSA algorithm. * Create a
45-
redirect URL back to the `/login/jwt-callback` path of your docs, including
46-
the JWT as the hash.
38+
Modify your existing login flow to include these steps after user authentication:
39+
40+
* Create a JWT containing the authenticated user's info in the `User` format. See [Sending Data](/authentication-personalization/sending-data) for more information.
41+
* Sign the JWT with your secret key, using the EdDSA algorithm.
42+
* Create a redirect URL back to the `/login/jwt-callback` path of your docs, including the JWT as the hash.
4743
</Step>
4844
</Steps>
4945

@@ -54,16 +50,15 @@ Your documentation is hosted at `docs.foo.com` with an existing authentication s
5450
Create a login endpoint at `https://foo.com/docs-login` that extends your existing authentication.
5551

5652
After verifying user credentials:
57-
58-
- Generate a JWT with user data in Mintlify's format.
59-
- Sign the JWT and redirect to `https://docs.foo.com/login/jwt-callback#{SIGNED_JWT}`.
53+
* Generate a JWT with user data in Mintlify's format.
54+
* Sign the JWT and redirect to `https://docs.foo.com/login/jwt-callback#{SIGNED_JWT}`.
6055

6156
<CodeGroup>
6257
```ts TypeScript
6358
import * as jose from 'jose';
6459
import { Request, Response } from 'express';
6560

66-
const TWO_WEEKS_IN_MS = 1000 _ 60 _ 60 _ 24 _ 7 \* 2;
61+
const TWO_WEEKS_IN_MS = 1000 * 60 * 60 * 24 * 7 * 2;
6762

6863
const signingKey = await jose.importPKCS8(process.env.MINTLIFY_PRIVATE_KEY, 'EdDSA');
6964

@@ -77,15 +72,14 @@ export async function handleRequest(req: Request, res: Response) {
7772
},
7873
};
7974

80-
const jwt = await new jose.SignJWT(user)
81-
.setProtectedHeader({ alg: 'EdDSA' })
82-
.setExpirationTime('10 s') // 10 second JWT expiration
83-
.sign(signingKey);
75+
const jwt = await new jose.SignJWT(user)
76+
.setProtectedHeader({ alg: 'EdDSA' })
77+
.setExpirationTime('10 s') // 10 second JWT expiration
78+
.sign(signingKey);
8479

85-
return res.redirect(`https://docs.foo.com/login/jwt-callback#${jwt}`);
80+
return res.redirect(`https://docs.foo.com/login/jwt-callback#${jwt}`);
8681
}
87-
88-
````
82+
```
8983

9084
```python Python
9185
import jwt # pyjwt
@@ -113,8 +107,7 @@ async def return_mintlify_auth_status(current_user):
113107
)
114108

115109
return RedirectResponse(url=f'https://docs.foo.com/login/jwt-callback#{jwt_token}', status_code=302)
116-
````
117-
110+
```
118111
</CodeGroup>
119112

120113
### Redirecting unauthenticated users
@@ -125,42 +118,38 @@ When an unauthenticated user tries to access a protected page, their intended de
125118
2. Redirect to your login URL with a redirect query parameter: `https://foo.com/docs-login?redirect=%2Fquickstart`.
126119
3. After authentication, redirect to `https://docs.foo.com/login/jwt-callback?redirect=%2Fquickstart#{SIGNED_JWT}`.
127120
4. User lands in their original destination.
128-
</Tab>
121+
</Tab>
129122
<Tab title="OAuth 2.0">
130-
131123
### Prerequisites
132124

133-
- An OAuth server that supports the Authorization Code Flow.
134-
- Ability to create an API endpoint accessible by OAuth access tokens (optional, to enable personalization features).
125+
* An OAuth server that supports the Authorization Code Flow.
126+
* Ability to create an API endpoint accessible by OAuth access tokens (optional, to enable personalization features).
135127

136128
### Implementation
137129

138130
<Steps>
139131
<Step title="Configure your OAuth settings.">
140-
1. In your dashboard, go to
141-
[Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
142-
2. Select **Full Authentication** or **Partial Authentication**. 3. Select
143-
**OAuth** and configure these fields: * **Authorization URL**: Your OAuth
144-
endpoint. * **Client ID**: Your OAuth 2.0 client identifier. * **Client
145-
Secret**: Your OAuth 2.0 client secret. * **Scopes**: Permissions to
146-
request. Use multiple scopes if you need different access levels. * **Token
147-
URL**: Your OAuth token exchange endpoint. * **Info API URL** (optional):
148-
Endpoint to retrieve user info for personalization. If omitted, the OAuth
149-
flow will only be used to verify identity and the user info will be empty.
132+
1. In your dashboard, go to [Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
133+
2. Select **Full Authentication** or **Partial Authentication**.
134+
3. Select **OAuth** and configure these fields:
135+
* **Authorization URL**: Your OAuth endpoint.
136+
* **Client ID**: Your OAuth 2.0 client identifier.
137+
* **Client Secret**: Your OAuth 2.0 client secret.
138+
* **Scopes**: Permissions to request. Use multiple scopes if you need different access levels.
139+
* **Token URL**: Your OAuth token exchange endpoint.
140+
* **Info API URL** (optional): Endpoint to retrieve user info for personalization. If omitted, the OAuth flow will only be used to verify identity and the user info will be empty.
150141
4. Select **Save changes**.
151142
</Step>
152143
<Step title="Configure your OAuth server.">
153-
1. Copy the **Redirect URL** from your [authentication
154-
settings](https://dashboard.mintlify.com/settings/deployment/authentication).
144+
1. Copy the **Redirect URL** from your [authentication settings](https://dashboard.mintlify.com/settings/deployment/authentication).
155145
2. Add the redirect URL as an authorized redirect URL for your OAuth server.
156146
</Step>
157147
<Step title="Create your user info endpoint (optional).">
158-
To enable personalization features, create an API endpoint that: * Accepts
159-
OAuth access tokens for authentication. * Returns user data in the `User`
160-
format. See [Sending Data](/authentication-personalization/sending-data) for
161-
more information. Add this endpoint URL to the **Info API URL** field in
162-
your [authentication
163-
settings](https://dashboard.mintlify.com/settings/deployment/authentication).
148+
To enable personalization features, create an API endpoint that:
149+
* Accepts OAuth access tokens for authentication.
150+
* Returns user data in the `User` format. See [Sending Data](/authentication-personalization/sending-data) for more information.
151+
152+
Add this endpoint URL to the **Info API URL** field in your [authentication settings](https://dashboard.mintlify.com/settings/deployment/authentication).
164153
</Step>
165154
</Steps>
166155

@@ -169,7 +158,6 @@ When an unauthenticated user tries to access a protected page, their intended de
169158
Your documentation is hosted at `foo.com/docs` and you have an existing OAuth server at `auth.foo.com` that supports the Authorization Code Flow.
170159

171160
**Configure your OAuth server details** in your dashboard:
172-
173161
- **Authorization URL**: `https://auth.foo.com/authorization`
174162
- **Client ID**: `ydybo4SD8PR73vzWWd6S0ObH`
175163
- **Scopes**: `['docs-user-info']`
@@ -189,27 +177,25 @@ Your documentation is hosted at `foo.com/docs` and you have an existing OAuth se
189177
```
190178

191179
**Configure your OAuth server to allow redirects** to your callback URL.
192-
193180
</Tab>
194181
<Tab title="Mintlify Dashboard">
195182
### Prerequisites
196183

197-
- Your documentation users are also your documentation editors.
184+
* Your documentation users are also your documentation editors.
198185

199186
### Implementation
200187

201188
<Steps>
202189
<Step title="Enable Mintlify dashboard authentication.">
203-
1. In your dashboard, go to
204-
[Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
205-
2. Select **Full Authentication** or **Partial Authentication**. 3. Select
206-
**Mintlify Auth**. 4. Select **Enable Mintlify Auth**.
190+
1. In your dashboard, go to [Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
191+
2. Select **Full Authentication** or **Partial Authentication**.
192+
3. Select **Mintlify Auth**.
193+
4. Select **Enable Mintlify Auth**.
207194
</Step>
208195
<Step title="Add authorized users.">
209-
1. In your dashboard, go to
210-
[Members](https://dashboard.mintlify.com/settings/organization/members). 2.
211-
Add each person who should have access to your documentation. 3. Assign
212-
appropriate roles based on their editing permissions.
196+
1. In your dashboard, go to [Members](https://dashboard.mintlify.com/settings/organization/members).
197+
2. Add each person who should have access to your documentation.
198+
3. Assign appropriate roles based on their editing permissions.
213199
</Step>
214200
</Steps>
215201

@@ -220,7 +206,6 @@ Your documentation is hosted at `docs.foo.com` and your team uses the dashboard
220206
**Enable Mintlify authentication** in your dashboard settings.
221207

222208
**Verify team access** by checking that all team members are added to your organization.
223-
224209
</Tab>
225210
<Tab title="Password">
226211
<Info>
@@ -229,16 +214,17 @@ Password authentication provides access control only and does **not** support co
229214

230215
### Prerequisites
231216

232-
- Your security requirements allow sharing passwords among users.
217+
* Your security requirements allow sharing passwords among users.
233218

234219
### Implementation
235220

236221
<Steps>
237222
<Step title="Create a password.">
238-
1. In your dashboard, go to
239-
[Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
240-
2. Select **Full Authentication** or **Partial Authentication**. 3. Select
241-
**Password**. 4. Enter a secure password. 5. Select **Save changes**.
223+
1. In your dashboard, go to [Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
224+
2. Select **Full Authentication** or **Partial Authentication**.
225+
3. Select **Password**.
226+
4. Enter a secure password.
227+
5. Select **Save changes**.
242228
</Step>
243229
<Step title="Distribute access.">
244230
Securely share the password and documentation URL with authorized users.
@@ -247,9 +233,8 @@ Password authentication provides access control only and does **not** support co
247233

248234
## Example
249235

250-
Your documentation is hosted at `docs.foo.com` and you need basic access control without tracking individual users. You want to prevent public access while keeping setup simple.
236+
Your documentation is hosted at `docs.foo.com` and you need basic access control without tracking individual users. You want to prevent public access while keeping setup simple.
251237

252238
**Create a strong password** in your dashboard. **Share credentials** with authorized users. That's it!
253-
254239
</Tab>
255240
</Tabs>

0 commit comments

Comments
 (0)