Managing user roles and permissions
You can manage user roles and permissions of your app from the user management dashboard.
#
InitialisationTo begin configuring user roles and permissions on the user management dashboard, start by initializing the "UserRoles" recipe in the recipeList
on the backend.
- NodeJS
- GoLang
- Python
- Other Frameworks
Important
import SuperTokens from "supertokens-node";
import Dashboard from "supertokens-node/recipe/dashboard";
import UserRoles from "supertokens-node/recipe/userroles"
SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "...",
},
recipeList: [
// TODO: Initialise other recipes if needed.
Dashboard.init(),
UserRoles.init()
],
});
Note
Please note that the capability to manage roles and permissions from the user management dashboard is available only from Node SDK version v16.6.0
onwards.
import (
"github.com/supertokens/supertokens-golang/recipe/dashboard"
"github.com/supertokens/supertokens-golang/recipe/userroles"
"github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
supertokens.Init(supertokens.TypeInput{
RecipeList: []supertokens.Recipe{
// TODO: Initialise other recipes if needed
dashboard.Init(nil),
userroles.Init(nil),
},
});
}
from supertokens_python import init, InputAppInfo
from supertokens_python.recipe import dashboard, userroles
init(
app_info=InputAppInfo(
api_domain="...", app_name="...", website_domain="..."),
framework='...',
recipe_list=[
# TODO: Initialise other recipes if needed.
dashboard.init(),
userroles.init()
]
)
- NodeJS
- GoLang
- Python
- Other Frameworks
Important
#
Managing roles and permissionsWhen you first use the UserRoles
recipe, the list of roles will be empty. To create roles, simply click on the "Add Role" button.
This action will open a modal, enabling you to create a role along with its associated permissions. Permissions are essentially a list of strings assigned to a specific role.
After creating a role, the UI should display a list of all roles in your app.
You can now preview the role you created by clicking on the role row. The modal provides options to edit or delete the role.
#
Manging roles and usersTo assign a specific role to a user, start by finding the user in the dashboard. Upon clicking the user, navigate to the user details page where you'll find a section for user roles.
If the selected user is associated with multiple tenants, you can choose a 'tenantId' from the dropdown menu to specify the tenant for which you'd like to assign roles.
Click the edit button to start assigning roles. Then, select the "Assign Role" button, and a modal will appear with a list of available roles for assignment to this user.
To remove a role assigned to a user, simply click on the "X" icon next to that specific role.
important
Our Python SDK doesn't currently support roles management via the user management UI. Instead, you can use the functions exposed by the SDK to manage roles and permissions. Check out the guide here.
important
Our Golang SDK doesn't currently support roles management via the user management UI. Instead, you can use the functions exposed by the SDK to manage roles and permissions. Check out the guide here.