Skip to content

Commit 775de05

Browse files
committed
add draft of auth overview and oauth flow
1 parent 3377f9c commit 775de05

File tree

4 files changed

+73
-5
lines changed

4 files changed

+73
-5
lines changed

fern/products/docs/docs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ navigation:
168168
- section: Authentication
169169
collapsed: true
170170
contents:
171-
- page: SSO
172-
path: ./pages/authentication/sso.mdx
171+
- page: Overview
172+
path: ./pages/authentication/overview.mdx
173173
- page: Role based access control (RBAC)
174174
path: ./pages/authentication/rbac.mdx
175175
slug: rbac
176176
- page: API Key Injection
177177
path: ./pages/api-references/autopopulate-api-key.mdx
178+
- page: SSO
179+
path: ./pages/authentication/sso.mdx
178180
- section: Enterprise
179181
collapsed: true
180182
contents:

fern/products/docs/pages/api-references/autopopulate-api-key.mdx

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@ Fern can integrate with your authentication flow, allowing users to login and ha
1313

1414
With this feature, you can **create new users of your API** directly from within your documentation.
1515

16-
## How it works
16+
## Choosing your auth flow
17+
18+
API key injection can work in two different ways depending on your company's authentication setup: **JWT or OAuth**.
19+
20+
* **JWT Flow:** You handle the entire auth flow and just give Fern a JWT cookie
21+
* **OAuth Flow:** You give Fern access, and Fern directly handles the OAuth handshake process
22+
23+
<AccordionGroup>
24+
<Accordion title="JWT" toc={true}>
25+
26+
### How it works
1727

1828
To enable this feature, you need to configure authentication so that Fern can securely retrieve API keys for your users. The process works as follows:
1929

@@ -80,8 +90,38 @@ The JWT should have a structure similar to:
8090
## Setting up auto-populated API keys
8191

8292
- [ ] Reach out to Fern to get your secret key
83-
- [ ] Send Fern the URL of your authentication page (this is where users will be redirected to after clicking the "Login" button in the API Explorer)
93+
- [ ] Send Fern the URL of your authentication page. This is where users will be redirected to after clicking the "Login" button in the API Explorer.
8494
- [ ] Add logic to your service to set the `fern_token` cookie when a user logs in
8595

8696
<Tip>For an example of how to set up the `fern_token` cookie, see our demo implementation [here](https://github.com/fern-api/fern-platform/blob/app/packages/fern-docs/bundle/src/app/%5Bhost%5D/%5Bdomain%5D/api/fern-docs/auth/fern-token-demo/route.ts).</Tip>
8797

98+
</Accordion>
99+
<Accordion title="OAuth" toc={true}>
100+
101+
### How it works
102+
103+
To enable this feature, you need to configure OAuth authentication so that Fern can securely retrieve API keys for your users through your OAuth provider. Here's how the process works:
104+
105+
1. When a user clicks the "Login" button in the API Explorer, Fern initiates an OAuth flow by making a request to your authorization endpoint.
106+
1. The user is redirected to your OAuth provider's login page where they authenticate using your existing auth system.
107+
1. After successful authentication, your OAuth provider redirects back to Fern with an authorization code, which Fern exchanges for an access token at your token endpoint.
108+
1. Fern uses this token to retrieve the user's API key and automatically populates it in the API Explorer.
109+
110+
### Setting up auto-populated API keys
111+
112+
To enable API key injection, you'll need to:
113+
- [ ] Set up an authenticated account for Fern so Fern can authorize users on your behalf. Provide Fern with
114+
- [ ] Configure your OAuth application to return user API keys when Fern requests them
115+
116+
Then, you'll need to send Fern the following items:
117+
- The client ID and client secret for Fern's authenticated account
118+
- The URL of your authentication endpoint. This is where users will be redirected to after clicking the "Login" button in the API Explorer.
119+
- The URL of your token endpoint. This is where Fern exchanges codes for tokens.
120+
121+
</Accordion>
122+
</AccordionGroup>
123+
124+
125+
126+
127+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Overview of authentication options
3+
description: Understand the different authentication options Fern offers
4+
---
5+
6+
Fern offers two methods of authentication, Single Sign-On (SSO) and Role-Based Access Control (RBAC).
7+
8+
**For most situations, we recommend using RBAC** for granular access control over your documentation. RBAC works well for sites with multiple audiences (internal teams, partners, customers) and supports API key injection to auto-populate code examples.
9+
10+
**SSO is simpler** but only provides basic login functionality - it doesn't support role-based permissions or API key injection. SSO works well for internal-only documentation where everyone should see the same content.
11+
12+
**API Key Injection** (available with RBAC only) can be set up using either JWT or OAuth, depending on your existing authentication system.
13+
14+
Learn more about Fern's authentication options:
15+
16+
<CardGroup cols={3}>
17+
<Card title="Role-based access control" icon="fa-duotone fa-people-group" href="/docs/authentication/rbac">
18+
Granular access for different audiences
19+
</Card>
20+
<Card title="API Key Injection" icon="fa-duotone fa-key" href="/docs/authentication/api-key-injection">
21+
Set up API Key Injection using JWT or OAuth.
22+
</Card>
23+
<Card title="SSO" icon="fa-duotone fa-user-check" href="/docs/authentication/sso">
24+
Set up a simple authentication system.
25+
</Card>
26+
</CardGroup>

fern/products/docs/pages/authentication/sso.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Single Sign-On
33
subtitle: Enterprise authentication for secure access to your Fern dashboard
44
---
55

6-
Fern’s Single Sign-On (SSO) is an enterprise feature that lets your team securely access the Fern dashboard at `dashboard.buildwithfern.com` using your organization’s identity provider. This is designed for internal contributors, such as technical writers, product managers, or engineers, who need access to want to contribute to your documentation, view web analytics, or manage organizational settings.
6+
Fern’s Single Sign-On (SSO) is an enterprise feature that lets your team securely access your Fern Docs site through your organization’s identity provider. This is designed for internal contributors, such as technical writers, product managers, or engineers, who need access to want to contribute to your documentation, view web analytics, or manage organizational settings.
77

88
## What SSO unlocks
99

0 commit comments

Comments
 (0)