Set up JWT

Self-managed authentication integrated with your login system

View as Markdown

With JWT, you manage the entire auth flow. This involves building and signing a fern_token cookie that integrates your docs with your existing login system. Like OAuth, JWT enables:

How it works

  1. A user clicks Login on your docs site and is redirected to your authentication page.
  2. After authentication, your system signs a JWT with a secret key from Fern and sets it as a fern_token cookie.
  3. Fern reads the token to determine the user’s access and credentials.

Configuration

1

Get your secret key

Reach out to Fern to get your secret key and send them the URL of your authentication page. This is where users are redirected after clicking Login.

2

Build the fern claim

The JWT payload must include a fern claim. What you include in the token’s fern claim controls which features are enabled: login only, RBAC, or API key injection.

1{
2 "fern": {}
3}
4

Enable RBAC or API key injection (optional)

Once your fern_token is working, configure the features you need:

  • Role-based access control — define roles in docs.yml and restrict navigation items or page content by role.
  • API key injection — configure the playground payload, including custom headers, multiple API keys, and per-environment credentials.