Skip to content

Commit 1116da3

Browse files
committed
update setup
1 parent 5b5cd25 commit 1116da3

File tree

1 file changed

+83
-9
lines changed

1 file changed

+83
-9
lines changed

protected-pages/setup.mdx

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

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.
109

1110
<Info>
1211
Authentication methods are available on [Growth and Enterprise plans](https://mintlify.com/pricing?ref=authentication).
1312
</Info>
1413

15-
## Configuring authentication
14+
## Protected pages setup
15+
16+
TODO: verify steps with new UI
1617

1718
Select the handshake method that you want to configure.
1819

@@ -37,7 +38,7 @@ Select the handshake method that you want to configure.
3738
<Step title="Integrate Mintlify authentication into your login flow.">
3839
Modify your existing login flow to include these steps after user authentication:
3940

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.
4142
* Sign the JWT with your secret key, using the EdDSA algorithm.
4243
* Create a redirect URL back to the `/login/jwt-callback` path of your docs, including the JWT as the hash.
4344
</Step>
@@ -123,7 +124,7 @@ When an unauthenticated user tries to access a protected page, their intended de
123124
### Prerequisites
124125

125126
* 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).
127128

128129
### Implementation
129130

@@ -137,17 +138,17 @@ When an unauthenticated user tries to access a protected page, their intended de
137138
* **Client Secret**: Your OAuth 2.0 client secret.
138139
* **Scopes**: Permissions to request. Use multiple scopes if you need different access levels.
139140
* **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.
141142
4. Select **Save changes**.
142143
</Step>
143144
<Step title="Configure your OAuth server.">
144145
1. Copy the **Redirect URL** from your [authentication settings](https://dashboard.mintlify.com/settings/deployment/authentication).
145146
2. Add the redirect URL as an authorized redirect URL for your OAuth server.
146147
</Step>
147148
<Step title="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:
149150
* 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.
151152

152153
Add this endpoint URL to the **Info API URL** field in your [authentication settings](https://dashboard.mintlify.com/settings/deployment/authentication).
153154
</Step>
@@ -207,4 +208,77 @@ Your documentation is hosted at `docs.foo.com` and your team uses the dashboard
207208

208209
**Verify team access** by checking that all team members are added to your organization.
209210
</Tab>
211+
<Tab title="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+
<Step title="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+
<Step title="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.
256+
2. **Add CORS headers** for this route only:
257+
* `Access-Control-Allow-Origin`: `https://docs.foo.com`
258+
* `Access-Control-Allow-Credentials`: `true`
259+
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.
282+
</Note>
283+
</Tab>
210284
</Tabs>

0 commit comments

Comments
 (0)