Skip to content

Commit f03e142

Browse files
committed
Refinements
1 parent 3598503 commit f03e142

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

docs/guides/billing/for-b2b.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ You can create a pricing page by using the [`<PricingTable />`](/docs/reference/
5050

5151
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.
5252

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.
5455
5556
The `has()` method is available for any JavaScript framework, while `<Protect>` is only available for React-based frameworks.
5657

docs/guides/organizations/roles-and-permissions.mdx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The **Creator** role must _at least_ have the following [system permissions](#sy
3535

3636
To reassign the **Creator** role:
3737

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).
3939
1. [Create a new role](#custom-roles) or use an existing role from the list.
4040
1. Ensure that **Manage members**, **Read members**, and **Delete organization** system permissions are selected for the role.
4141
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
4949

5050
To reassign the **Default** role:
5151

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).
5353
1. [Create a new role](#custom-roles) or use an existing role from the list.
5454
1. Open the three dots icon for the role.
5555
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
6565

6666
To create a new role:
6767

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**.
7272

7373
### Change a user's role
7474

@@ -85,13 +85,18 @@ To change a user's role in the Clerk Dashboard:
8585

8686
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.
8787

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).
8989
1. Select the three dots icon next to the role.
9090
1. Select **Delete role**.
9191

9292
## Permissions
9393

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.
95100
96101
### System permissions
97102

@@ -111,22 +116,24 @@ Clerk's system permissions consist of the following:
111116
You can assign these system permissions to any role.
112117

113118
> [!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).
115120
116-
### Custom permissions
121+
### Feature permissions
117122

118123
> [!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.
122125
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.
124127

125-
To create a new permission:
128+
To create a new custom permission:
126129

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>`.
130137
> [!NOTE]
131138
> Common permission values could be:
132139
>
@@ -138,6 +145,8 @@ To create a new permission:
138145
> 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`).
139146
1. Select **Create permission**.
140147

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+
141150
## Verify a user's role or permission
142151

143152
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).

docs/guides/secure/authorization-checks.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This guide will show you how to implement authorization checks in order to prote
4141
- 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.
4242
- 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.
4343
- 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.
4545

4646
<If sdk="nextjs">
4747
* 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

Comments
 (0)