You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: protected-pages/setup.mdx
+83-9Lines changed: 83 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,17 +2,18 @@
2
2
title: "Protected pages setup"
3
3
description: "Guarantee privacy of your docs by authenticating users"
4
4
icon: "file-lock"
5
-
keywords: ['auth']
5
+
keywords: ['auth', 'authentication']
6
6
---
7
-
Authentication requires users to log in before accessing your documentation. This guide covers setup for each available handshake method.
8
7
9
-
**Need help choosing?** See the [overview](/authentication-personalization/overview)to compare options.
8
+
This guide covers setup for each available handshake method to control access to your documentation.
10
9
11
10
<Info>
12
11
Authentication methods are available on [Growth and Enterprise plans](https://mintlify.com/pricing?ref=authentication).
13
12
</Info>
14
13
15
-
## Configuring authentication
14
+
## Protected pages setup
15
+
16
+
TODO: verify steps with new UI
16
17
17
18
Select the handshake method that you want to configure.
18
19
@@ -37,7 +38,7 @@ Select the handshake method that you want to configure.
37
38
<Steptitle="Integrate Mintlify authentication into your login flow.">
38
39
Modify your existing login flow to include these steps after user authentication:
39
40
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
+
* Create a JWT containing the authenticated user's info in the `User` format. See [Sending Data](/protected-pages/sending-data) for more information.
41
42
* Sign the JWT with your secret key, using the EdDSA algorithm.
42
43
* Create a redirect URL back to the `/login/jwt-callback` path of your docs, including the JWT as the hash.
43
44
</Step>
@@ -123,7 +124,7 @@ When an unauthenticated user tries to access a protected page, their intended de
123
124
### Prerequisites
124
125
125
126
* 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).
127
+
* Ability to create an API endpoint accessible by OAuth access tokens (optional, to enable API prefilling features).
127
128
128
129
### Implementation
129
130
@@ -137,17 +138,17 @@ When an unauthenticated user tries to access a protected page, their intended de
137
138
***Client Secret**: Your OAuth 2.0 client secret.
138
139
***Scopes**: Permissions to request. Use multiple scopes if you need different access levels.
139
140
***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.
141
+
***Info API URL** (optional): Endpoint to retrieve user info for API prefilling. If omitted, the OAuth flow will only be used to verify identity and the user info will be empty.
141
142
4. Select **Save changes**.
142
143
</Step>
143
144
<Steptitle="Configure your OAuth server.">
144
145
1. Copy the **Redirect URL** from your [authentication settings](https://dashboard.mintlify.com/settings/deployment/authentication).
145
146
2. Add the redirect URL as an authorized redirect URL for your OAuth server.
146
147
</Step>
147
148
<Steptitle="Create your user info endpoint (optional).">
148
-
To enable personalization features, create an API endpoint that:
149
+
To enable API playground prefilling, create an API endpoint that:
149
150
* 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
+
* Returns user data in the `User` format. See [Sending Data](/protected-pages/sending-data) for more information.
151
152
152
153
Add this endpoint URL to the **Info API URL** field in your [authentication settings](https://dashboard.mintlify.com/settings/deployment/authentication).
153
154
</Step>
@@ -207,4 +208,77 @@ Your documentation is hosted at `docs.foo.com` and your team uses the dashboard
207
208
208
209
**Verify team access** by checking that all team members are added to your organization.
209
210
</Tab>
211
+
<Tabtitle="Shared session">
212
+
### Prerequisites
213
+
TODO: verify this is still an option
214
+
215
+
* A dashboard or user portal with cookie-based session authentication.
216
+
* Ability to create an API endpoint at the same origin or subdomain as your dashboard.
217
+
* If your dashboard is at `foo.com`, the **API URL** must start with `foo.com` or `*.foo.com`.
218
+
* If your dashboard is at `dash.foo.com`, the **API URL** must start with `dash.foo.com` or `*.dash.foo.com`.
219
+
* Your docs are hosted at the same domain or subdomain as your dashboard.
220
+
* If your dashboard is at `foo.com`, your **docs** must be hosted at `foo.com` or `*.foo.com`.
221
+
* If your dashboard is at `*.foo.com`, your **docs** must be hosted at `foo.com` or `*.foo.com`.
222
+
223
+
### Implementation
224
+
225
+
<Steps>
226
+
<Steptitle="Create user info API endpoint.">
227
+
Create an API endpoint that:
228
+
* Uses your existing session authentication to identify users
229
+
* Returns user data in the `User` format (see [Sending Data](/protected-pages/sending-data))
230
+
* If the API domain and the docs domain **do not exactly match**:
231
+
* Add the docs domain to your API's `Access-Control-Allow-Origin` header (must not be `*`).
232
+
* Set your API's `Access-Control-Allow-Credentials` header to `true`.
233
+
234
+
<Warning>
235
+
Only enable CORS headers on this specific endpoint, not your entire dashboard API.
236
+
</Warning>
237
+
</Step>
238
+
<Steptitle="Configure your settings.">
239
+
1. In your dashboard, go to [Authentication](https://dashboard.mintlify.com/settings/deployment/authentication).
240
+
2. Select **Personalization**.
241
+
3. Select **Shared Session**.
242
+
4. Enter your **Info API URL**, which is the endpoint from the first step.
243
+
5. Enter your **Login URL**, where users log into your dashboard.
244
+
6. Select **Save changes**.
245
+
</Step>
246
+
</Steps>
247
+
248
+
### Examples
249
+
250
+
#### Dashboard at subdomain, docs at subdomain
251
+
252
+
You have a dashboard at `dash.foo.com`, which uses cookie-based session authentication. Your dashboard API routes are hosted at `dash.foo.com/api`. You want to set up personalization for your docs hosted at `docs.foo.com`.
253
+
254
+
**Setup process**:
255
+
1.**Create endpoint**`dash.foo.com/api/docs/user-info` that identifies users via session authentication and responds with their user data.
3.**Configure API URL** in authentication settings: `https://dash.foo.com/api/docs/user-info`.
260
+
261
+
#### Dashboard at subdomain, docs at root
262
+
263
+
You have a dashboard at `dash.foo.com`, which uses cookie-based session authentication. Your dashboard API routes are hosted at `dash.foo.com/api`. You want to set up personalization for your docs hosted at `foo.com/docs`.
264
+
265
+
**Setup process**:
266
+
1.**Create endpoint**`dash.foo.com/api/docs/user-info` that identifies users via session authentication and responds with their user data.
267
+
2.**Add CORS headers** for this route only:
268
+
*`Access-Control-Allow-Origin`: `https://foo.com`
269
+
*`Access-Control-Allow-Credentials`: `true`
270
+
3.**Configure API URL** in authentication settings: `https://dash.foo.com/api/docs/user-info`.
271
+
272
+
#### Dashboard at root, docs at root
273
+
274
+
You have a dashboard at `foo.com/dashboard`, which uses cookie-based session authentication. Your dashboard API routes are hosted at `foo.com/api`. You want to set up personalization for your docs hosted at `foo.com/docs`.
275
+
276
+
**Setup process**:
277
+
1.**Create endpoint**`foo.com/api/docs/user-info` that identifies users via session authentication and responds with their user data.
278
+
2.**Configure API URL** in authentication settings: `https://foo.com/api/docs/user-info`
279
+
280
+
<Note>
281
+
No CORS configuration is needed since the dashboard and docs share the same domain.
0 commit comments