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: docs/guides/billing/for-b2b.mdx
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,8 @@ You can create a pricing page by using the [`<PricingTable />`](/docs/reference/
50
50
51
51
You can use Clerk's features, plans, and permissions to gate access to content using [**authorization checks**](/docs/guides/secure/authorization-checks). There are a few ways to do this, but the recommended approach is to either use the [`has()`](/docs/reference/backend/types/auth-object#has) method or the [`<Protect>`](/docs/reference/components/control/protect) component.
52
52
53
-
Permission-based authorization checks link with feature-based authorization checks. This means that if you are checking a custom permission, it will only work if the feature part of the permission key (`org:<feature>:<permission>`) **is a feature included in the organization's active plan**. For example, say you want to check if an organization member has the custom permission `org:teams:manage`, where `teams` is the feature. Before performing the authorization check, you need to ensure that the user's organization is subscribed to a plan that has the `teams` feature. If the user's organization is not subscribed to a plan that has the `teams` feature, the authorization check will always return `false`, even if the user has the custom permission.
53
+
> [!IMPORTANT]
54
+
> Permission-based authorization checks link with feature-based authorization checks. This means that a permission check will only work if the feature part of the permission key (`org:<feature>:<permission>`) **is a feature included in the organization's active plan**. For example, say you want to check if an organization member has the custom permission `org:teams:manage`, where `teams` is the feature. Before performing the authorization check, you need to ensure that the user's organization is subscribed to a plan that has the `teams` feature. If not, the authorization check will always return `false`, even if the user has the custom permission.
54
55
55
56
The `has()` method is available for any JavaScript framework, while `<Protect>` is only available for React-based frameworks.
Copy file name to clipboardExpand all lines: docs/guides/organizations/roles-and-permissions.mdx
+27-18Lines changed: 27 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ The **Creator** role must _at least_ have the following [system permissions](#sy
35
35
36
36
To reassign the **Creator** role:
37
37
38
-
1. In the Clerk Dashboard, navigate to [**Roles**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles).
38
+
1. In the Clerk Dashboard, navigate to [**Roles & Permissions**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles).
39
39
1.[Create a new role](#custom-roles) or use an existing role from the list.
40
40
1. Ensure that **Manage members**, **Read members**, and **Delete organization** system permissions are selected for the role.
41
41
1. Open the three dots icon for the role.
@@ -49,7 +49,7 @@ You cannot delete an organization role if it's used as the organization's **Defa
49
49
50
50
To reassign the **Default** role:
51
51
52
-
1. In the Clerk Dashboard, navigate to [**Roles**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles).
52
+
1. In the Clerk Dashboard, navigate to [**Roles & Permissions**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles).
53
53
1.[Create a new role](#custom-roles) or use an existing role from the list.
54
54
1. Open the three dots icon for the role.
55
55
1. From the dropdown, select the **Set as Default role** option.
@@ -65,10 +65,10 @@ Custom roles can be granted permissions and access. For example, you can create
65
65
66
66
To create a new role:
67
67
68
-
1. In the Clerk Dashboard, navigate to [**Roles**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles)
69
-
1. Select **Create new role**.
70
-
1. Give the role a name, a key to reference it by in the format `org:<role>`, and a description.
71
-
1. Select **Create role**.
68
+
1. In the Clerk Dashboard, navigate to [**Roles & Permissions**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles)
69
+
1. Select **Add role**.
70
+
1. Give the role a name, a key to reference it by, and a description. The final key will follow the format `org:<role>`.
71
+
1. Select **Save**.
72
72
73
73
### Change a user's role
74
74
@@ -85,13 +85,18 @@ To change a user's role in the Clerk Dashboard:
85
85
86
86
You cannot delete a role that is still assigned to members of an organization. Change the members to a different role before completing the following steps.
87
87
88
-
1. In the Clerk Dashboard, navigate to [**Roles**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles).
88
+
1. In the Clerk Dashboard, navigate to [**Roles & Permissions**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles).
89
89
1. Select the three dots icon next to the role.
90
90
1. Select **Delete role**.
91
91
92
92
## Permissions
93
93
94
-
Permissions grant users privileged access to resources and operations, like creating and deleting. Clerk supports two types of permissions: System and Custom.
94
+
Permissions grant users privileged access to resources and operations, like creating and deleting. Clerk supports two types of permissions: **System** and **Feature**.
95
+
96
+
> [!IMPORTANT]
97
+
> In the Clerk Dashboard, permissions appear in the format `<feature>:<permission>`. However, the `org:` prefix is automatically applied under the hood for all organization-scoped permissions. This means that when checking permissions in your code, always include the full key with the prefix (`org:<feature>:<permission>`).
98
+
>
99
+
> The examples and instructions in these docs follow the same `org:<feature>:<permission>` standard.
95
100
96
101
### System permissions
97
102
@@ -111,22 +116,24 @@ Clerk's system permissions consist of the following:
111
116
You can assign these system permissions to any role.
112
117
113
118
> [!WARNING]
114
-
> System permissions aren't included in [session claims](/docs/guides/sessions/session-tokens#default-claims). To check permissions on the server-side, you must [create custom permissions](#custom-permissions).
119
+
> System permissions aren't included in [session claims](/docs/guides/sessions/session-tokens#default-claims). To check permissions on the server-side, you must [create feature permissions](#feature-permissions).
115
120
116
-
### Custom permissions
121
+
### Feature permissions
117
122
118
123
> [!WARNING]
119
-
> Custom permissions require a [paid plan](/pricing){{ target: '_blank' }} and the Enhanced B2B SaaS Add-on for production use, but free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
120
-
121
-
When creating a new permission, follow the format `org:<feature>:<permission>`. You can then assign the permission to an existing role.
124
+
> Feature permissions require a [paid plan](/pricing){{ target: '_blank' }} and the Enhanced B2B SaaS Add-on for production use, but free to use in development mode so that you can try out what works for you. See the [pricing](/pricing){{ target: '_blank' }} page for more information.
122
125
123
-
For example, you could create a new permission called **Create invoices** (`org:invoices:create`) which allows only users with this permission to edit invoices. Then, you could assign this permission to a role, or multiple roles, such as **Billing** (`org:billing`) or **Sales** (`org:sales`).
126
+
Custom permissions let you define fine-tuned access control within your organization. Each permission is tied to a feature, and can be assigned to one or more roles. To create a custom permission, you must first create a role (e.g. **sales**) and a feature within that role (e.g. **invoices**). Once both exist, you can define specific permissions (e.g. **create**) related to that feature.
124
127
125
-
To create a new permission:
128
+
To create a new custom permission:
126
129
127
-
1. In the Clerk Dashboard, navigate to [**Permissions**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles).
128
-
1. Select **Create new permission**.
129
-
1. Give the permission a name, a key to reference it by in the format `org:<feature>:<permission>`, and a description.
130
+
1. In the Clerk Dashboard, navigate to [**Roles & Permissions**](https://dashboard.clerk.com/last-active?path=organizations-settings/roles).
131
+
1.[Create a new role](#custom-roles) or use an existing role from the list.
132
+
1. Under **Feature permissions**, select **Create feature permission**.
133
+
1. Give the feature a name, a key to reference it by, and a description. The final key will follow the format `org:<feature>`.
134
+
1. Select **Add feature**.
135
+
1. Under the newly created feature, select **Create permission**.
136
+
1. Give the permission a name, a key to reference it by, and a description. The final key will follow the format `org:<feature>:<permission>`.
130
137
> [!NOTE]
131
138
> Common permission values could be:
132
139
>
@@ -138,6 +145,8 @@ To create a new permission:
138
145
> For example, you could create a new permission called **Create invoices** (`org:invoices:create`) which allows only users with this permission to edit invoices. Then, you could assign this permission to a role, or multiple roles, such as **Billing** (`org:billing`) or **Sales** (`org:sales`).
139
146
1. Select **Create permission**.
140
147
148
+
You can also create a custom permission by navigating to the [**Features**](https://dashboard.clerk.com/last-active?path=features) tab in the Clerk Dashboard, and following steps 6-8 above.
149
+
141
150
## Verify a user's role or permission
142
151
143
152
It's best practice to always verify whether or not a user is **authorized** to access sensitive information, important content, or exclusive features. **Authorization** is the process of determining the access rights and privileges of a user, ensuring they have the necessary permissions to perform specific actions. To perform authorization checks using a user's role or permission, see the [guide on authorizing users](/docs/guides/secure/authorization-checks).
Copy file name to clipboardExpand all lines: docs/guides/secure/authorization-checks.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ This guide will show you how to implement authorization checks in order to prote
41
41
- Note: Using `has()`**on the server-side** to check permissions works only with **custom permissions**, as [system permissions](/docs/guides/organizations/roles-and-permissions#system-permissions) aren't included in the session token claims. To check system permissions, verify the user's role instead.
42
42
- Checking for a role or permission depends on the user having an [active organization](!active-organization). Without an active organization, the authorization checks will likely always evaluate to false by default.
43
43
- If you would like to perform role-based authorization checks **without** using Clerk's organizations feature, see [the Role Based Access Control (RBAC) guide](/docs/guides/secure/basic-rbac).
44
-
- Permission-based authorization checks link with feature-based authorization checks. This means that if you are checking a custom permission, it will only work if the feature part of the permission key (`org:<feature>:<permission>`) **is a feature included in the organization's active plan**. For example, say you want to check if an organization member has the custom permission `org:teams:manage`, where `teams` is the feature. Before performing the authorization check, you need to ensure that the user's organization is subscribed to a plan that has the `teams` feature. If the user's organization is not subscribed to a plan that has the `teams` feature, the authorization check will always return `false`, even if the user has the custom permission.
44
+
- Permission-based authorization checks link with feature-based authorization checks. This means that a permission check will only work if the feature part of the permission key (`org:<feature>:<permission>`) **is a feature included in the organization's active plan**. For example, say you want to check if an organization member has the custom permission `org:teams:manage`, where `teams` is the feature. Before performing the authorization check, you need to ensure that the user's organization is subscribed to a plan that has the `teams` feature. If not, the authorization check will always return `false`, even if the user has the custom permission.
45
45
46
46
<Ifsdk="nextjs">
47
47
* Be cautious when doing authorization checks in layouts, as these don't re-render on navigation, meaning the user session won't be checked on every route change. [Read more in the Next.js docs](https://nextjs.org/docs/app/building-your-application/authentication#layouts-and-auth-checks).
0 commit comments