You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/docs/pages/authentication/rbac.mdx
+14-18Lines changed: 14 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,14 +24,17 @@ Role-based access control is helpful for scenarios such as:
24
24
25
25
### How it works
26
26
27
-
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.
27
+
Every user automatically has the `everyone` role, including unauthenticated visitors. Pages marked with the `everyone` role are publicly accessible without needing to log in.
28
+
29
+
If a user visits content that requires authentication (i.e., content not marked as visible to `everyone`), Fern checks for an authentication cookie to determine the user's roles. If the user lacks the required role or isn't authenticated, Fern redirects them to the login URL you provided during setup.
28
30
29
31
## Set up RBAC
30
32
31
33
<Steps>
34
+
32
35
### Define all the `roles` in your docs.yml
33
36
34
-
Start by defining all the different roles in your `docs.yml`. You can specify this under a `roles` key:
37
+
Start by using a `roles` key to define all the different roles:
35
38
36
39
```yml docs.yml
37
40
roles:
@@ -41,23 +44,17 @@ roles:
41
44
- admins
42
45
```
43
46
44
-
<Info>
45
-
The `everyone` role is special. Every user has this role (including unauthenticated users).
46
-
</Info>
47
-
48
47
### Configure authentication via a `fern_token`
49
48
50
-
In this step, we will configure authentication so that Fern can understand what roles a particular user has.
49
+
Fern uses a browser cookie called `fern_token` to identify authenticated users and their roles. If this cookie is not present when a user tries to access restricted content, Fern redirects them to your login page.
51
50
52
-
Fern expects the user's browser session to have a cookie called `fern_token`. If
53
-
the cookie is not present, the user will be redirected to your company's login
54
-
page.
55
-
56
-
Below, we walk through each of the steps required to configure RBAC with either JWT or OAuth.
51
+
You can set up this authentication using either JWT or OAuth:
57
52
58
53
<AccordionGroup>
59
54
<Accordion title="JWT">
60
-
**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`.
55
+
**You are responsible for creating and setting the `fern_token` cookie in your authentication system.**
56
+
57
+
Upon login, set a JWT for the user using a secret key that Fern provides. The JWT must include a `fern` claim with a `roles` array:
61
58
62
59
```json
63
60
{
@@ -72,8 +69,7 @@ Below, we walk through each of the steps required to configure RBAC with either
72
69
</Accordion>
73
70
<Accordion title="OAuth">
74
71
75
-
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.
76
-
You are responsible for configuring your OAuth endpoints to return user role information.
72
+
When a user needs authentication, Fern initiates an OAuth flow and redirects them to your authentication endpoint. You configure your OAuth endpoints to return user role information.
77
73
78
74
<Markdown src="/snippets/oauth-diagram.mdx"/>
79
75
@@ -82,9 +78,9 @@ You are responsible for configuring your OAuth endpoints to return user role inf
<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>
83
+
<Note title="Optional">If you'd like restricted pages to be visible but locked to unauthenticated users (rather than completely hidden), notify Fern during this step.</Note>
88
84
89
85
</Steps>
90
86
@@ -99,7 +95,7 @@ You can designate viewers on the following navigation items:
99
95
- `api references`
100
96
- `changelogs`
101
97
102
-
If you don't specify viewers, the content will be visible to _any authenticated user_.
98
+
If you don't specify viewers, the content will be visible to any _authenticated_ user. To make content publicly accessible, explicitly set viewers to `everyone`.
0 commit comments