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
description: "Guarantee privacy of your docs by authenticating users"
4
4
icon: "file-lock"
5
5
---
6
+
Authentication requires users to log in before accessing your documentation. This guide covers setup for each available handshake method.
7
+
8
+
**Need help choosing?** See the [overview](/authentication-personalization/overview) to compare options.
6
9
7
10
<Info>
8
11
Authentication methods are available on the [Growth and Enterprise plans](https://mintlify.com/pricing?ref=authentication). Please{""}
9
12
<ahref="mailto:[email protected]">contact sales</a> for more information.
10
13
</Info>
11
14
12
-
Authentication offers full privacy for all of your
13
-
documentation content by requiring users to authenticate before viewing any content, such as:
15
+
## Configuring authentication
16
+
17
+
Select the handshake method that you want to configure.
18
+
19
+
<Tabs>
20
+
<Tabtitle="JWT">
21
+
### Prerequisites
22
+
23
+
* An authentication system that can generate and sign JWTs.
24
+
* A backend service that can create redirect URLs.
25
+
26
+
### Implementation
27
+
28
+
<Steps>
29
+
<Steptitle="Generate a private key.">
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.
36
+
</Step>
37
+
<Steptitle="Integrate Mintlify authentication into your login flow.">
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.
43
+
</Step>
44
+
</Steps>
45
+
46
+
### Example
47
+
Your documentation is hosted at `docs.foo.com` with an existing authentication system at `foo.com`. You want to extend your login flow to grant access to the docs.
48
+
49
+
To do this, create a login endpoint at `https://foo.com/docs-login` that extends your existing authentication.
50
+
51
+
After verifying user credentials:
52
+
* Generate a JWT with user data in Mintlify's format.
53
+
* Sign the JWT and redirect to `https://docs.foo.com/login/jwt-callback#{SIGNED_JWT}`.
When an unauthenticated user tries to access a protected page, their intended destination is automatically preserved:
115
+
116
+
1. User attempts to visit a protected page: `https://docs.foo.com/quickstart`.
117
+
2. Redirect to your login URL with a redirect query parameter: `https://foo.com/docs-login?redirect=%2Fquickstart`.
118
+
3. After authentication, redirect to `https://docs.foo.com/login/jwt-callback?redirect=%2Fquickstart#{SIGNED_JWT}`.
119
+
4. User lands in their original destination.
120
+
</Tab>
121
+
<Tabtitle="OAuth 2.0">
122
+
### Prerequisites
123
+
124
+
- You have an existing OAuth server that supports the Authorization Code flow.
125
+
- You can create a new API endpoint that can be accessed by the returned OAuth access token.
126
+
127
+
### Implementation
128
+
129
+
<Steps>
130
+
<Steptitle="Configure your Authentication settings">
131
+
Go to your [Mintlify authentication settings](https://dashboard.mintlify.com/products/authentication), select the OAuth option, and fill out the required fields:
132
+
133
+
-**Authorization URL**: The base URL for the authorization request, to which we will add the appropriate query parameters.
134
+
-**Client ID**: An ID for the OAuth 2.0 client to be used.
135
+
-**Scopes**: An array of scopes that will be requested. TODO: clarify why there could be multiple
136
+
-**Token URL**: The base URL for the token exchange request.
137
+
-**Info API URL** (optional): The endpoint that will be hit to retrieve user info. If omitted, the OAuth flow will only be used to verify identity, and the user info will be empty.
138
+
</Step>
139
+
<Steptitle="Configure your OAuth client">
140
+
Copy the Redirect URL listed in the [Mintlify authentication settings](https://dashboard.mintlify.com/products/authentication) and add it as an authorized redirect URL for your OAuth server.
141
+
</Step>
142
+
<Steptitle="Create your Info API (Optional)">
143
+
If you want to take advantage of authentication's customization features, you'll need to create an endpoint to retrieve info about your users.
144
+
Create an API endpoint that can be accessed with an OAuth access token, and responds with a JSON payload following the [User](../sending-data) format.
145
+
146
+
Return to your [Mintlify authentication settings](https://dashboard.mintlify.com/products/authentication) and add the Info API URL
147
+
to your OAuth configuration.
148
+
</Step>
149
+
</Steps>
150
+
151
+
## Example
152
+
153
+
I have an existing OAuth server that supports the Authorization Code flow. I want to set up authentication for my docs hosted at `foo.com/docs`.
154
+
155
+
To set up authentication with Mintlify, I create an endpoint `api.foo.com/docs/user-info` which requires an OAuth access token with the `docs-user-info` scope, and responds with the user's custom data according to Mintlify’s specification.
156
+
157
+
I then go to the dashboard settings, navigate to the Authentication settings, select OAuth, and enter the relevant values for the OAuth flow and Info API endpoint:
-**Info API URL**: `https://api.foo.com/docs/user-info`
163
+
164
+
Finally, I copy the Redirect URL displayed in the dashboard settings and add it as an authorized redirect URL in my OAuth client configuration settings.
165
+
166
+
167
+
</Tab>
168
+
<Tabtitle="Mintlify Dashboard">
169
+
### Prerequisites
170
+
171
+
- Your documentation readers are also your documentation editors.
172
+
173
+
### Implementation
174
+
175
+
### Example
176
+
177
+
I want to set up authentication for my docs hosted at `docs.foo.com`. I want my docs
178
+
to be internal, and the people that will be viewing my docs are the same people that
179
+
contribute to my docs.
180
+
181
+
To set up authentication with Mintlify, I can go to my [dashboard settings](https://dashboard.mintlify.com/products/authentication)
182
+
and enable Authentication with the Mintlify Auth Handshake.
183
+
184
+
I can then ensure that anyone that should be able to read the docs has been added as a user in
185
+
my [dashboard settings](https://dashboard.mintlify.com/settings/organization/members).
186
+
187
+
## Implementation
188
+
189
+
<Steps>
190
+
<Steptitle="Configure your Authentication settings">
191
+
Go to your [Mintlify dashboard
192
+
settings](https://dashboard.mintlify.com/products/authentication) and select
193
+
the Mintlify Auth Handshake.
194
+
</Step>
195
+
<Steptitle="Add users">
196
+
Ensure that any users that should be able to view your documentation have
0 commit comments