Skip to content

Commit 9cd57cb

Browse files
author
Kapil Gowru
committed
feat: merged
2 parents c25e166 + 223d3bc commit 9cd57cb

File tree

17 files changed

+338
-75
lines changed

17 files changed

+338
-75
lines changed

fern/assets/styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,12 @@ a[href*="changelog"] svg {
940940
pointer-events: none;
941941
}
942942

943+
/* Fade out effect for AI animation */
944+
.rive-container.fade-bottom {
945+
mask: linear-gradient(to bottom, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
946+
-webkit-mask: linear-gradient(to bottom, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
947+
}
948+
943949
.rive-container canvas {
944950
width: 100%;
945951
height: 100%;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## 0.65.39
2+
**`(fix):`** Fix snippet generation for local file system output mode. Snippets configured with `snippets.path`
3+
in generators.yml were not being generated when using `--local` flag due to missing Docker volume
4+
mounting for the downloadFiles output mode.
5+
6+

fern/products/docs/docs.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ navigation:
7979
path: ./pages/component-library/custom-components/reusable-markdown.mdx
8080
- page: Custom React Components
8181
path: ./pages/component-library/custom-components/custom-react-components.mdx
82+
- page: Conditionally Rendered Content
83+
hidden: true
84+
path: ./pages/component-library/custom-components/conditional-rendering.mdx
8285
- section: Customization
8386
collapsed: true
8487
contents:
@@ -168,13 +171,15 @@ navigation:
168171
- section: Authentication
169172
collapsed: true
170173
contents:
171-
- page: SSO
172-
path: ./pages/authentication/sso.mdx
174+
- page: Overview
175+
path: ./pages/authentication/overview.mdx
173176
- page: Role based access control (RBAC)
174177
path: ./pages/authentication/rbac.mdx
175178
slug: rbac
176179
- page: API Key Injection
177180
path: ./pages/api-references/autopopulate-api-key.mdx
181+
- page: SSO
182+
path: ./pages/authentication/sso.mdx
178183
- section: Enterprise
179184
collapsed: true
180185
contents:

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

Lines changed: 51 additions & 3 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+
## Integrating with 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 initiates the OAuth handshake process
22+
23+
<AccordionGroup toc={true}>
24+
<Accordion title="JWT" toc={true}>
25+
26+
### How the JWT flow 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

@@ -77,11 +87,49 @@ The JWT should have a structure similar to:
7787

7888
</CodeBlocks>
7989

80-
## Setting up auto-populated API keys
90+
#### Architecture diagram
91+
92+
<Markdown src="/snippets/jwt-auth-diagram.mdx"/>
93+
94+
#### Setting up auto-populated API keys
8195

8296
- [ ] 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)
97+
- [ ] 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.
8498
- [ ] Add logic to your service to set the `fern_token` cookie when a user logs in
8599

86100
<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>
87101

102+
</Accordion>
103+
<Accordion title="OAuth" toc={true}>
104+
105+
### How the OAuth flow works
106+
107+
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:
108+
109+
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.
110+
1. The user is redirected to your OAuth provider's login page where they authenticate using your existing auth system.
111+
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.
112+
1. Fern sets a `fern_token` cookie containing the user's authentication credentials and automatically populates their API key in the API Explorer.
113+
114+
#### Architecture diagram
115+
116+
<Markdown src="/snippets/oauth-diagram.mdx"/>
117+
118+
#### Setting up auto-populated API keys
119+
120+
To enable API key injection, you'll need to:
121+
- [ ] Set up an authenticated account for Fern so Fern can authorize users on your behalf.
122+
- [ ] Configure your OAuth application to return user API keys when Fern requests them
123+
124+
Then, you'll need to send Fern the following items:
125+
- The client ID and client secret for Fern's authenticated account
126+
- The URL of your authentication endpoint. This is where users will be redirected to after clicking the "Login" button in the API Explorer.
127+
- The URL of your token endpoint. This is where Fern exchanges codes for tokens.
128+
129+
</Accordion>
130+
</AccordionGroup>
131+
132+
133+
134+
135+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
API key injection can be set up using either JWT or OAuth, depending on your existing authentication system.
11+
12+
**SSO is simpler** but only provides basic login functionality - it doesn't support RBAC or API key injection. SSO works well for internal-only documentation where everyone should see the same content.
13+
14+
15+
16+
Learn more about Fern's authentication options:
17+
18+
<CardGroup cols={3}>
19+
<Card title="Role-based access control" icon="fa-duotone fa-people-group" href="/docs/authentication/rbac">
20+
Granular access for different audiences
21+
</Card>
22+
<Card title="API Key Injection" icon="fa-duotone fa-key" href="/docs/authentication/api-key-injection">
23+
JWT or OAuth flows available
24+
</Card>
25+
<Card title="SSO" icon="fa-duotone fa-user-check" href="/docs/authentication/sso">
26+
Basic functionality and simple setup
27+
</Card>
28+
</CardGroup>

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

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,43 +24,6 @@ Role-based access control is helpful for scenarios such as:
2424

2525
If a user visits content not marked as visible to the `everyone` role, Fern will check for an authentication cookie to indicate what roles that user has. If the user does not have a role matching the viewers of the page, we will redirect them to the URL you provided during setup.
2626

27-
Below, we walk through each of the steps required to configure RBAC.
28-
29-
### Architecture diagram
30-
31-
```mermaid
32-
sequenceDiagram
33-
participant U as User
34-
participant F as Fern Docs
35-
participant R as Redirect URL
36-
participant A as Auth System
37-
38-
U->>F: Visit restricted page
39-
F->>F: Check fern_token cookie
40-
41-
alt Cookie exists
42-
F->>F: Decode JWT with secret key
43-
F->>F: Extract roles from JWT
44-
F->>F: Check if user has required role
45-
46-
alt User has required role
47-
F->>U: Show restricted content
48-
else User lacks required role
49-
F->>U: User is shown a 404 page
50-
end
51-
else No cookie
52-
F->>R: Redirect to login page
53-
R->>A: Authenticate user
54-
end
55-
56-
Note over A: User logs in
57-
58-
A->>A: Generate JWT with roles
59-
A->>F: Set fern_token cookie
60-
F->>F: Validate JWT and roles
61-
F->>U: Show restricted content
62-
```
63-
6427
## Set up RBAC
6528

6629
<Steps>
@@ -82,10 +45,16 @@ The `everyone` role is special. Every user has this role (including unauthentica
8245

8346
### Configure authentication via a `fern_token`
8447

85-
In this step, we will configure authentication so that Fern can understand what roles a particular user has. Fern expects the user's
86-
browser session to have a cookie called `fern_token`. If the cookie is not present, the user will be redirected to your company's
87-
login page.
48+
In this step, we will configure authentication so that Fern can understand what roles a particular user has.
49+
50+
Fern expects the user's browser session to have a cookie called `fern_token`. If
51+
the cookie is not present, the user will be redirected to your company's login
52+
page.
8853

54+
Below, we walk through each of the steps required to configure RBAC with either JWT or OAuth.
55+
56+
<AccordionGroup>
57+
<Accordion title="JWT">
8958
**You are responsible for creating and setting the `fern_token` cookie in your authentication system.** Upon login, you must set a JWT for the user using a secret key that we will provide. The JWT must have a `fern` claim with a key called `roles`.
9059

9160
```json
@@ -96,11 +65,22 @@ login page.
9665
}
9766
```
9867

99-
### Contact Fern for setup
68+
<Markdown src="/snippets/jwt-auth-diagram.mdx"/>
10069

101-
When you're ready to implement RBAC, **contact [email protected]** to receive your secret key for JWT signing.
70+
</Accordion>
71+
<Accordion title="OAuth">
72+
73+
Fern initiates an OAuth flow when the user needs authentication, redirecting them to your authentication endpoint. Fern creates and sets the `fern-token` cookie after completing this flow.
74+
You are responsible for configuring your OAuth endpoints to return user role information.
75+
76+
<Markdown src="/snippets/oauth-diagram.mdx"/>
77+
78+
</Accordion>
79+
</AccordionGroup>
80+
81+
### Contact Fern for setup
10282

103-
You'll also need to provide the URL where Fern should send unauthenticated users to log in.
83+
When you're ready to implement RBAC, **contact [email protected]**.
10484

10585
<Note>Optional: If you'd like restricted pages to be visible but locked to unauthenticated users (rather than completely hidden), let us know during this step.</Note>
10686

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
11
---
22
title: Single Sign-On
3-
subtitle: Enterprise authentication for secure access to your Fern dashboard
3+
subtitle: Enterprise authentication for secure access to your docs
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 docs through your organization’s identity provider.
7+
8+
<Note>SSO does not support Role-Based Access Control or API Key Injection.</Note>
79

810
## What SSO unlocks
911

10-
When SSO is enabled for your organization, authenticated users of Fern gain access to:
12+
When SSO is enabled for your organization, authenticated users of Fern can:
1113

12-
- **Manage Users of your Organization**: Add teammates and configure settings for your organization
13-
- **Access Ask Fern Analytics**: See AI-assisted search usage and browse verbatim user questions
14-
- **View Web Analytics**: Track key site metrics, like page views and unique visitors **(coming soon)**
1514
- **Use the Visual Editor**: Make edits to your docs from the browser
15+
- **Send Authenticated Preview Links** Only authenticated users can view [preview links](docs/preview-publish/previewing-changes-locally)
1616

1717
## How it works
1818

19-
Fern's SSO integration allows your team to use their existing corporate credentials to access the Fern dashboard. Instead of managing separate Fern accounts, users authenticate through your organization's identity provider and are automatically granted appropriate access to your Fern resources.
19+
Fern's SSO integration allows your team to use their existing corporate credentials to access your Fern Docs site.
20+
21+
### Architecture diagram
22+
23+
```mermaid
24+
sequenceDiagram
25+
participant U as User
26+
participant F as Fern Docs
27+
participant I as Identity Provider
28+
29+
U->>F: Click "Login"
30+
F->>I: Redirect to SSO login
31+
32+
Note over I: User authenticates with corporate credentials
33+
34+
I->>I: Validate user credentials
35+
I->>F: Redirect back with fern_token
36+
F->>F: Grant access to organizational features
37+
F->>U: Show docs site
38+
```
2039

2140
## Supported identity providers
2241

@@ -25,6 +44,7 @@ Fern supports SSO integration with any identity provider that implements industr
2544
- **SAML 2.0**: Compatible with providers like Okta, OneLogin, Azure AD, and others
2645
- **OIDC (OpenID Connect)**: Works with Google Workspace, Auth0, and other OIDC-compliant providers
2746

28-
<Note>
29-
SSO is available as part of the Enterprise plan. Reach out via Slack or [contact our team](https://buildwithfern.com/contact) to begin the SSO setup process.
30-
</Note>
47+
## Setting up SSO
48+
49+
SSO is available as part of the Enterprise plan. Reach out via Slack or [contact our team](https://buildwithfern.com/contact) to begin the SSO setup process. Fern will work with one of your security administrators to connect to your identity provider.
50+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Conditionally Rendered Content
3+
---
4+
5+
You can conditionally render content based on the instance or version of the docs, in addition to the role of an authenticated user.
6+
7+
## Conditionally render content
8+
9+
### Between instances
10+
11+
Define instances in your `docs.yml` file:
12+
13+
```yaml docs.yml
14+
instances:
15+
- url: fern-dev.docs.buildwithfern.com
16+
name: development
17+
- url: fern-prod.docs.buildwithfern.com
18+
name: production
19+
```
20+
21+
```mdx conditional-rendering.mdx
22+
<If instance={["development"]}>
23+
This is a beta feature. It should only be available when the docs have been generated with the `development` instance.
24+
</If>
25+
26+
<If instance={["production"]}>
27+
This is a production feature. It should only be available when the docs have been generated with the `production` instance.
28+
</If>
29+
```
30+
31+
### Between versions
32+
33+
```mdx conditional-rendering.mdx
34+
<If version={["v1"]}>
35+
This is an old feature. It should only be available when the user is on the `v1` version.
36+
</If>
37+
38+
<If version={["v2"]}>
39+
This is a new feature. It should only be available when the user is on the `v2` version.
40+
</If>
41+
```
42+
43+
### Based on the role of an authenticated user
44+
45+
```mdx conditional-rendering.mdx
46+
<If viewer={["admin"]}>
47+
This is an admin feature. It should only be available when the user is an admin.
48+
</If>
49+
```

fern/products/home/pages/welcome.mdx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ import { FernFooter } from "../../../components/FernFooter";
132132
</div>
133133

134134
{/* Rive Animation */}
135-
<div class="rive-container">
136-
<canvas id="docs-rive-canvas"></canvas>
137-
</div>
135+
<a href="/docs/getting-started/overview" style="cursor: pointer; text-decoration: none;">
136+
<div class="rive-container fade-bottom">
137+
<canvas id="docs-rive-canvas"></canvas>
138+
</div>
139+
</a>
138140

139141
<div className="action-buttons-vertical">
140142
<a className="fern-button filled normal primary gap-1 w-fit a-btn" href="/docs/getting-started/overview">
@@ -190,9 +192,11 @@ import { FernFooter } from "../../../components/FernFooter";
190192
</div>
191193

192194
{/* Rive Animation */}
193-
<div class="rive-container">
194-
<canvas id="ai-rive-canvas"></canvas>
195-
</div>
195+
<a href="/ask-fern/getting-started/what-is-ask-fern" style="cursor: pointer; text-decoration: none;">
196+
<div class="rive-container fade-bottom">
197+
<canvas id="ai-rive-canvas"></canvas>
198+
</div>
199+
</a>
196200

197201
<div className="action-buttons">
198202
<a className="fern-button filled normal primary gap-1 a-btn" href="/ask-fern/getting-started/what-is-ask-fern">
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 2.1.4
2+
**`(fix):`** ensure that query parameters are Uri encodeded in RawClient.cs
3+

0 commit comments

Comments
 (0)