Role-Based Access Control
Roles and Permissions
Descope allows you to assign roles and permissions to the application's end user. Users with Descope admin privileges can define roles and permissions in the Descope console. Permissions and roles are represented as strings in Descope. Your application must do the interpretation and enforcement of the roles and permissions.
Permission Creation
Permissions are used within roles. Within the Permissions tab
of the console, under Authorization you can create and manage your permissions. Clicking the + Permission
Button
at the top right allows you to create the permission. You can also click the three dots to the right of the permission
to delete the permission or change it's description.
Role Creation
Within the Roles tab of the console, under Authorization you can
create and manage your roles. Clicking the + Role
Button at the top right allows you to create the role. You
can also click the three dots to the right of the role to delete the role, change it's description, or add
permissions to the role.
Configuring User's Roles
Each user that is created in your application (during sign-up) can be assigned roles and permissions. The user can get more than one role and will include the role's associated permissions. The assignment of roles and permissions can be done manually (not recommended) using the console, using the management SDK (sample code below), or can be automatically mapped if you use SSO (SAML) as the authentication method for your application.
You can edit and add roles to users within the Users page.
Tenants and Roles
Roles have two main types, Tenant
and Project
. Every role that's configured in a specific project, will either be specific to a Tenant or the entire Project, depending on this type.
When you create roles you have the option to assign them to a specific tenant with the respective Tenant ID, shown in the docs below.
If you are using tenants for user management, then the same user can be assigned different roles and permissions for each tenant (if you so desire). These can be automatically assigned using SSO Configuration too. The Tenant Management section covers the steps to configure roles mapping using SAML.
JWT Example
After successful end-user authentication, the roles and permissions are delivered to your application as part of the JWT token. Below is a sample JWT token that contains roles and permissions with a user logged into a tenant.
Validating Roles and Permissions
Examples of how to validate roles and permissions using the backend SDK are covered in our Session Management articles.
Authorization management using the management SDK
Install SDK
Import and initialize Management SDK
Load All Permissions
This Descope SDK allows administrators to return all details for permissions configured within the Descope instance. The response includes an array of permissions and the details of each permission.
Create a Permissions
This Descope SDK allows administrators to create a new permission.
Update a Permissions
This Descope SDK allows administrators to update an existing permission with the given various fields. It is important to note that parameters are used as overrides to the existing permission; empty fields will override populated fields.
Delete a Permissions
This Descope SDK allows administrators to delete an existing permission. It is important to note that this action is irreversible.
Load All Roles
This Descope SDK allows administrators to return all details for roles configured within the Descope instance. The response includes an array of roles and the details of each role.
Search for Roles
This Descope SDK allows administrators to return specific roles configured within the Descope instance using several parameters. The response includes an array of roles and the details of each role.
Create a Role
This Descope SDK allows administrators to create a new role.
Update a Role
This Descope SDK allows administrators to update an existing role with the given various fields. It is important to note that parameters are used as overrides to the existing role; empty fields will override populated fields.
Delete a Role
This Descope SDK allows administrators to delete an existing role. It is important to note that this action is irreversible.