Creating custom roles and policies
Read time: 6 minutes
Last edited: Mar 01, 2024
Overview
This topic explains how to create and implement custom roles and policies in LaunchDarkly.
If you need to use custom roles to address a scenario not covered in the documentation, you can write your own policies with the advanced editor. To learn more, read Using the advanced editor. For examples, read Example policies and templates.
Creating a custom role
Before you can give an account member custom permissions in LaunchDarkly, you must create a custom role to assign to them.
To create a custom role:
- Navigate to Account settings.
- Click into the Roles tab.
- Click Create role. The "Create custom role" panel appears.
- Enter a human-readable Name for the role.
- Enter a Key for the role.
- (Optional) Enter a Description to explain what the role does.
- (Optional) To create a role with no access to any resources, uncheck "By default, members can view all LaunchDarkly content."
- Create a policy in the "Policy" fields.
- Click Save role.
You can also use the REST API: Create custom role
Understanding starting roles
LaunchDarkly uses the built-in Reader role as the starting point for new custom roles when you create them. If you keep the By default, members can view all LaunchDarkly content box checked, the custom role starts with Reader permissions. You can use the role's policy to remove view permissions or allow the ability to modify resources.
You can also create custom roles with no access to any LaunchDarkly resources by unchecking the checkbox. To learn how, read Configuring roles with no access.
Creating policies for custom roles
Policies are sets of actions a custom role is allowed or not allowed to take. You can create policies from the Roles tab.
Advanced members can write custom policies of their own with the advanced editor. To open the advanced editor, click Advanced editor in the "Role policy" section.
The advanced editor is powerful. Before you use it, read Using the advanced editor.
To create a policy:
- Complete the steps in Creating a custom role.
- In the "Create custom role" panel, click into the Choose resources for this policy statement field.
- Specify a resource this policy affects.
Many common LaunchDarkly items are resources, including flags, metrics, and more. If your LaunchDarkly project is large, it may be difficult to find the exact resource you need.
Click Resource finder to choose projects, feature flags, environments, metrics, and roles to add to your policy.
To learn more, read Finding resource IDs.
- Under Allow or deny actions on the resource, choose an effect from the menu.
- Under Choose actions to allow or deny, choose one or more actions for the policy to enforce:
- Click Update. The results of your policy display:
Finding resource IDs
You can find resource IDs with the resource finder, which you can access with the “resource finder” link in either the simple or advanced editor, or by using the keyboard shortcut ⌘
+ .
(Mac) or ctl
+ .
(Windows). All of your environments, members, feature flags, metrics, and roles will be available.
Here is a screenshot of the "Find a resource ID" dialog:
Giving an account member a custom role
After you have created a custom role and policies for it, you must give that role to all members to whom you wish it to apply.
To give a member a custom role:
- Navigate to Account settings.
- Click into the Members tab and find the account member you wish to give a custom role.
- Click that account member's name. The member's Permissions page opens.
- Click Edit member roles. A dialog appears.
- Choose Custom. A menu containing your organization's custom roles appears.
- Choose all the custom roles you wish to give the member.
- Click Save roles. You are returned to the permissions page.
You can also use the REST API: Modify an account member
You can use the Teams feature to group a set of members and assign them all the same custom roles. To learn more, read Teams.
You can also assign custom roles through your IdP with SSO or SCIM. For an in-depth guide on how to use custom roles with IdPs, read Creating custom roles.
Viewing an account member's roles
To view the roles for an individual account member, read Viewing an individual member's roles.
You can also use the REST API: Get account member
Removing an account member's custom role
If an account member changes function or needs their permissions modified, you can remove a custom role from them at any time.
To remove a custom role from a member:
- Navigate to Account settings.
- Click into the Members tab and find the account member you wish to remove a custom role from.
- Click that account member's name. The member's "Permissions" page opens.
- Click Edit member roles. The "Edit role" window appears:
- Click the X icon on all the custom roles you wish to remove from the member. You may also choose a built-in role for this member.
- Click Save roles.
Viewing custom role details
You can view details about a specific custom role. More information is available on the "Role policy details" panel.
Use the "Role policy details" panel to view detailed information about a custom role, including which projects and feature flags the role has permission to modify. You can also view each action the custom role can perform and what that action does.
Here is a screenshot of the "Role policy details" panel:
To view details for custom roles from the Roles tab:
- Navigate to Account settings and click into the Roles tab.
- Find the role with details you wish to view and click Details or Edit. The "Role policy details" panel appears.
To view details for custom roles in other parts of the LaunchDarkly user interface (UI), click a custom role's name to open the "Role policy details" panel:
You can also use the REST API: Get custom role
Editing existing custom roles
Edit an existing policy at any time by clicking the pencil edit icon or add a new policy to a custom role by clicking Add statement.
To edit a custom role:
- Navigate to Account settings.
- Click into the Roles tab and find the role you wish to edit.
- Click Edit role. The "Edit custom role policy" panel appears.
- Change whatever features of the role you wish.
- Click Save changes.
You can also use the REST API: Update custom role
Deleting custom roles
Delete a custom role from the Account settings page.
To delete a custom role:
- Navigate to Account settings.
- Click into the Roles tab and find the role you wish to edit.
- Click Edit role. The "Edit custom role" panel appears.
- Click Delete role.
You can also use the REST API: Delete custom role