Configure user authentication for your site with OAuth, JWT, password, or shared links to control access to pages and API references.
Docfiy dashboard authentication is available on all plans.
Password, OAuth, and JWT authentication require an Enterprise plan.
Authentication is only available for sites hosted on a custom domain or Docfiy subdomain (for example, docs.example.com or example.docfiy.dev). Authentication is not supported when using a custom basepath (for example, example.com/docs).
Authentication requires users to log in before accessing your content.
You can configure full authentication for all pages or partial authentication where some pages are public and others are protected.
Configure authentication
Select the handshake method that you want to configure.
Password
Docfiy dashboard
OAuth 2.0
JWT
Password authentication provides access control only and does not support user-specific features like group-based access control or API playground pre-filling.
Password prerequisites
Your security requirements allow sharing passwords among users.
In the Password Protection section, enter a secure password
After you enter a password, your site redeploys. When it finishes deploying, anyone who visits your site must enter the password to access your content.
2
Distribute access.
Securely share the password and documentation URL with authorized users.
Password example
You host your documentation at docs.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.
Docfiy dashboard prerequisites
Everyone who needs to access your documentation must be a member of your Docfiy organization.
In the Custom Authentication section, click Docfiy Auth.
Click Enable Docfiy Auth.
After you enable Docfiy authentication, your site redeploys. When it finishes deploying, anyone who visits your site must log in to your Docfiy organization to access your content.
In the Custom Authentication section, click OAuth.
Configure these fields:
Authorization URL: Your OAuth endpoint.
Client ID: Your OAuth 2.0 client identifier.
Client Secret: Your OAuth 2.0 client secret.
Scopes (optional): Permissions to request. Copy the entire scope string (for example, for a scope like provider.users.docs, copy the complete provider.users.docs). Use multiple scopes if you need different access levels.
Additional authorization parameters (optional): Additional query parameters to add to the initial authorization request.
Token URL: Your OAuth token exchange endpoint.
Info API URL (optional): Endpoint on your server that Docfiy calls to retrieve user info. Required for group-based access control. If omitted, the OAuth flow only verifies identity.
Logout URL (optional): The native logout URL for your OAuth provider. When users log out, Docfiy validates the logout redirect against this configured URL for security. The redirect only succeeds if it exactly matches the configured logoutUrl. If you do not configure a logout URL, users redirect to /login. Docfiy redirects users with a GET request and does not append query parameters, so include any parameters (for example, returnTo) directly in the URL.
Redirect URL (optional): The URL to redirect users to after authentication.
Click Save changes.
After you configure your OAuth settings, your site redeploys. When it finishes deploying, anyone who visits your site must log in to your OAuth provider to access your content.
Control session length with the expiresAt field in your user info response. This is a Unix timestamp (seconds since epoch) indicating when the session should expire. See User data format for more details.
Configure your OAuth server to allow redirects to your callback URL.
JWT prerequisites
An authentication system that can generate and sign JWTs.
Store your key securely where it can be accessed by your backend.
After you generate a private key, your site redeploys. When it finishes deploying, anyone who visits your site must log in to your JWT authentication system to access your content.
2
Integrate Docfiy authentication into your login flow.
Modify your existing login flow to include these steps after user authentication:
Create a JWT containing the authenticated user's info in the User format. See User data format for more information.
Sign the JWT with your secret key, using the EdDSA algorithm.
Create a redirect URL back to the /login/jwt-callback path of your docs, including the JWT as the hash.
JWT example
You host your documentation 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 while keeping your docs separate from your dashboard (or you don't have a dashboard).
Create a login endpoint at https://foo.com/docs-login that extends your existing authentication.
After verifying user credentials:
Generate a JWT with user data in Docfiy's format.
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, the redirect to your login URL preserves the user's intended destination.
User attempts to visit a protected page: https://docs.foo.com/quickstart.
Redirect to your login URL with a redirect query parameter: https://foo.com/docs-login?redirect=%2Fquickstart.
After authentication, redirect to https://docs.foo.com/login/jwt-callback?redirect=%2Fquickstart#{SIGNED_JWT}.
User lands in their original destination.
Make pages public
When using authentication, all pages require authentication to access by default. You can make specific pages viewable without authentication at the page or group level with the public property.
Individual pages
To make a page public, add public: true to the page's frontmatter.
Public page example
Copy
Ask AI
---title: "Public page"public: true---
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.
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.
Manage groups through user data passed during authentication. See User data format for details.
Specify which groups can access specific pages using the groups property in frontmatter.
Example page restricted to the admin group highlight={3}
Copy
Ask AI
---title: "Admin dashboard"groups: ["admin"]---
Users must belong to at least one of the listed groups to access the page. If a user tries to access a page without the required group, they'll receive a 404 error.
How groups interact with public pages
All pages require authentication by default.
Pages with a groups property are only accessible to authenticated users in those groups.
Pages without a groups property are accessible to all authenticated users.
Pages with public: true and no groups property are accessible to everyone.
Copy
---title: "Public guide"public: true---
User data format
When using OAuth or JWT authentication, your system returns user data that controls session length, group membership, and content personalization.
Required for JWT authentication. The hostname of your documentation site. The string must exactly match the domain where you deploy your documentation. Docfiy validates that the JWT's host matches the requesting host to prevent token reuse across different sites.
Session expiration time in seconds since epoch. When the current time passes this value, the user must re-authenticate.
For JWT: This differs from the JWT's exp claim, which determines when a JWT is considered invalid. Set the JWT exp claim to a short duration (10 seconds or less) for security. Use expiresAt for the actual session length (hours to weeks).
Pre-fills API playground fields with user-specific values. When a user authenticates, these values populate the corresponding input fields in the API playground. Users can override pre-filled values, and their overrides persist in local storage.
Only values that match the current endpoint's security scheme are applied.