Pro plans include password authentication.Custom plans include all authentication methods.
Authentication modes
Choose between full and partial authentication modes based on your access control needs. Full authentication: All pages are protected. Users must log in before accessing any content. Partial authentication: Some pages are publicly viewable while others require authentication. Users can browse public content freely and authenticate only when accessing protected pages. When configuring any handshake method below, you’ll select either Full authentication or Partial authentication in your dashboard settings.Understanding token types
Different authentication methods use different token types. Understanding these tokens helps you configure authentication correctly and troubleshoot issues.Access tokens (OAuth)
Access tokens are short-lived credentials issued by your OAuth server after successful authentication. Mintlify uses these tokens to verify user identity and retrieve user information. Where to configure:- Your OAuth server issues access tokens automatically during the OAuth flow.
- Configure the Token URL in your authentication settings to specify where Mintlify exchanges authorization codes for access tokens.
- Configure the Info API URL to specify where Mintlify sends access tokens to retrieve user data.
- Token expiration: Set on your OAuth server. Typical values range from 1 hour to 24 hours.
- Token refresh: Configure refresh tokens on your OAuth server to allow seamless re-authentication.
- Scopes: Define in the Scopes field to control what permissions the access token grants. Use space-separated values like
openid profile emailor provider-specific scopes likeprovider.users.docs. - Token format: Most OAuth providers use opaque tokens or JWTs. Your Info API endpoint must accept whichever format your OAuth server issues.
API keys
API keys are long-lived credentials used to authenticate requests to your Info API endpoint. While Mintlify doesn’t directly use API keys for authentication, your backend may require them. Where to configure:- API keys are managed on your backend, not in Mintlify’s dashboard.
- Your Info API endpoint can require API keys in addition to OAuth access tokens for added security.
Bearer tokens
Bearer tokens are a type of access token transmitted in the Authorization header with the “Bearer” scheme. OAuth access tokens are typically sent as bearer tokens. Where to configure:- Bearer tokens are automatically used when you configure OAuth authentication.
- Your Info API endpoint receives bearer tokens in the format:
Authorization: Bearer {token}.
JWT tokens
JWT (JSON Web Token) tokens are self-contained tokens that encode user information and are cryptographically signed. Mintlify supports JWT authentication where you generate and sign tokens on your backend. Where to configure:- Generate a private key in your authentication settings.
- Store the private key securely in your backend environment.
- Sign JWTs with the EdDSA algorithm using your private key.
- Redirect users to
/login/jwt-callback#{SIGNED_JWT}after authentication.
- JWT expiration: Set with
setExpirationTime(). Keep this short (10-60 seconds) since the JWT is only used for the initial handshake. - Session expiration: Set with
expiresAtin the payload. This controls how long the user stays logged in (typically 1-2 weeks). - Algorithm: Must use EdDSA. Other algorithms are not supported.
- User data: Include any data you want available for personalization in the
contentfield.
Token security best practices
Follow these practices to keep your authentication secure.Protect your secrets
- Never commit secrets to version control. Use environment variables or secret management services.
- Rotate secrets regularly. Update OAuth client secrets and JWT private keys periodically.
- Use different secrets for different environments. Don’t share secrets between development, staging, and production.
Configure appropriate token lifetimes
- OAuth access tokens: 1-24 hours. Shorter lifetimes are more secure but may require more frequent re-authentication.
- JWT tokens: 10-60 seconds for the initial handshake. The JWT is only used once to establish a session.
- Session expiration: 1-2 weeks. Balance security with user convenience.
Validate tokens properly
- Verify token signatures. Always validate JWT signatures using your private key.
- Check token expiration. Reject expired tokens immediately.
- Validate token audience. Ensure tokens are intended for your application.
Secure your endpoints
- Use HTTPS only. Never transmit tokens over unencrypted connections.
- Implement rate limiting. Prevent brute force attacks on your authentication endpoints.
- Log authentication attempts. Monitor for suspicious activity.
Handle tokens securely in your application
- Don’t expose tokens in URLs. Use headers or POST bodies instead (except for the JWT callback redirect, which is designed for this purpose).
- Clear tokens on logout. Ensure tokens are removed from client storage.
- Implement token refresh. Use refresh tokens to obtain new access tokens without requiring re-authentication.
Common token-related issues
”Invalid token” errors
Symptoms: Users see authentication errors or are repeatedly prompted to log in. Causes and solutions:- Expired tokens: Check token expiration times. Increase token lifetime or implement token refresh.
- Clock skew: Ensure your server’s clock is synchronized. Use NTP to keep time accurate.
- Wrong algorithm: Verify you’re using EdDSA for JWT tokens. Other algorithms are not supported.
- Incorrect secret: Verify you’re using the correct private key or client secret.
OAuth callback failures
Symptoms: Users are redirected to your OAuth server but never return to the docs. Causes and solutions:- Incorrect redirect URL: Verify the redirect URL in your OAuth server matches the one in your authentication settings.
- Missing scopes: Ensure all required scopes are configured in both Mintlify and your OAuth server.
- Token exchange failure: Check your Token URL is correct and accessible.
Info API endpoint errors
Symptoms: Authentication succeeds but user data is not available or personalization doesn’t work. Causes and solutions:- Endpoint not accessible: Verify your Info API URL is publicly accessible and returns a 200 status.
- Invalid token format: Ensure your endpoint accepts bearer tokens in the Authorization header.
- Wrong response format: Verify your endpoint returns data in the correct User data format.
JWT signature verification failures
Symptoms: JWT authentication fails with signature errors. Causes and solutions:- Wrong key format: Ensure you’re importing the private key correctly using
jose.importPKCS8(). - Key mismatch: Verify you’re using the same key that was generated in your dashboard.
- Algorithm mismatch: Confirm you’re using EdDSA, not RS256 or other algorithms.
Session expiration issues
Symptoms: Users are logged out unexpectedly or sessions last too long. Causes and solutions:- Incorrect
expiresAtvalue: EnsureexpiresAtis in seconds (Unix timestamp), not milliseconds. - JWT expiration vs session expiration: Remember that JWT
expis for the token itself (short), whileexpiresAtis for the session (long).
Configure authentication
Select the handshake method that you want to configure.- Password
- Mintlify dashboard
- OAuth 2.0
- JWT
Password authentication provides access control only and does not support content personalization.
Prerequisites
- Your security requirements allow sharing passwords among users.
Implementation
1
Create a password.
- In your dashboard, go to Authentication.
- Select Full Authentication or Partial Authentication.
- Select Password.
- Enter a secure password.
- Select Save changes.
2
Distribute access.
Securely share the password and documentation URL with authorized users.
Example
Your documentation is hosted atdocs.foo.com and you need basic access control without tracking individual users. You want to prevent public access while keeping setup simple.Create a strong password in your dashboard. Share credentials with authorized users. That’s it!Make pages public
When using partial authentication, all pages are protected by default. You can make specific pages viewable without authentication at the page or group level with thepublic property.
Individual pages
To make a page public, addpublic: true to the page’s frontmatter.
Public page example
Groups of pages
To make all pages in a group public, add"public": true beneath the group’s name in the navigation object of your docs.json.
Public group example
Control access with groups
When you use OAuth or JWT authentication, you can restrict specific pages to certain user groups. This is useful when you want different users to see different content based on their role or attributes. Groups are managed through user data passed during authentication.Example user info
groups property in frontmatter.
Example page restricted to the admin group
Interaction with authentication modes
Groups work differently depending on your authentication mode. Full authentication with groups:- All pages require authentication.
- Pages without a
groupsproperty are accessible to all authenticated users. - Pages with a
groupsproperty are only accessible to authenticated users in those groups.
- Pages require authentication unless you make them public.
- Pages with
public: trueand nogroupsare accessible to everyone. - Pages with
groups(with or withoutpublic: true) are only accessible to authenticated users in those groups.
Anyone can view this page
Only authenticated users can view this page