Custom roles

Version history

Custom roles allow group members who are assigned the Owner role to create roles specific to the needs of their organization.

For a demo of the custom roles feature, see [Demo] Ultimate Guest can view code on private repositories via custom role.

The following granular permissions are available. You can add these permissions to any base role, and add them in combination with each other to create a customized role:

  • The Guest+1 role, which allows users with the Guest role to view code.
  • In GitLab 16.1 and later, you can create a custom role that can view vulnerability reports and change the status of the vulnerabilities.
  • In GitLab 16.3 and later, you can create a custom role that can view the dependency list.
  • In GitLab 16.4 and later, you can create a custom role that can approve merge requests.
  • In GitLab 16.5 and later, you can create a custom role that can manage group members.

You can discuss individual custom role and permission requests in issue 391760.

When you enable a custom role for a user with the Guest role, that user has access to elevated permissions, and therefore:

This does not apply to Guest+1, a Guest custom role that only enables the read_code permission. Users with that specific custom role are not considered billable users and do not use a seat.

Create a custom role

Prerequisites:

  • You must be an administrator for the self-managed instance, or have the Owner role in the group you are creating the custom role in.
  • The group must be in the Ultimate tier.
  • You must have:
    • At least one private project so that you can see the effect of giving a user with the Guest role a custom role. The project can be in the group itself or one of that group’s subgroups.
    • A personal access token with the API scope.

GitLab SaaS

Prerequisite:

  • You must have the Owner role in the group you are creating the custom role in.
  1. On the left sidebar, select Search or go to and find your group.
  2. Select Settings > Roles and Permissions.
  3. Select Add new role.
  4. In Base role to use as template, select Guest.
  5. In Role name, enter the custom role’s title.
  6. Select the Permissions for the new custom role.
  7. Select Create new role.

Self Managed GitLab Instances

Prerequisite:

  • You must be an administrator for the self-managed instance you are creating the custom role in.
  1. On the left sidebar, select Search or go to.
  2. Select Admin Area.
  3. Select Settings > Roles and Permissions.
  4. From the top dropdown list, select the group you want to create a custom role in.
  5. Select Add new role.
  6. In Base role to use as template, select Guest.
  7. In Role name, enter the custom role’s title.
  8. Select the Permissions for the new custom role.
  9. Select Create new role.

To create a custom role, you can also use the API.

Custom role requirements

For every ability, a minimal access level is defined. To be able to create a custom role which enables a certain ability, the member_roles table record has to have the associated minimal access level. For all abilities, the minimal access level is Guest. Only users who have at least the Guest role can be assigned to a custom role.

Some roles and abilities require having other abilities enabled. For example, a custom role can only have administration of vulnerabilities (admin_vulnerability) enabled if reading vulnerabilities (read_vulnerability) is also enabled.

You can see the abilities requirements in the following table.

AbilityRequired ability
read_code-
read_dependency-
read_vulnerability-
admin_merge_request-
admin_vulnerabilityread_vulnerability
admin_group_member-
manage_project_access_tokens-

Associate a custom role with an existing group member

To associate a custom role with an existing group member, a group member with the Owner role:

  1. Invites a user as a direct member to the root group or any subgroup or project in the root group’s hierarchy as a Guest. At this point, this Guest user cannot see any code on the projects in the group or subgroup.
  2. Optional. If the Owner does not know the id of the Guest user receiving a custom role, finds that id by making an API request.

  3. Associates the member with the Guest+1 role using the Group and Project Members API endpoint

    # to update a project membership
    curl --request PUT --header "Content-Type: application/json" --header "Authorization: Bearer <your_access_token>" --data '{"member_role_id": '<member_role_id>', "access_level": 10}' "https://gitlab.example.com/api/v4/projects/<project_id>/members/<user_id>"
    
    # to update a group membership
    curl --request PUT --header "Content-Type: application/json" --header "Authorization: Bearer <your_access_token>" --data '{"member_role_id": '<member_role_id>', "access_level": 10}' "https://gitlab.example.com/api/v4/groups/<group_id>/members/<user_id>"
    

    Where:

    • <project_id and <group_id>: The id or URL-encoded path of the project or group associated with the membership receiving the custom role.
    • <member_role_id>: The id of the member role created in the previous section.
    • <user_id>: The id of the user receiving a custom role.

    Now the Guest+1 user can view code on all projects associated with this membership.

Remove a custom role

Prerequisite:

  • You must be an administrator or have the Owner role in the group you are removing the custom role from.

You can remove a custom role from a group only if no group members have that role.

To do this, you can either remove the custom role from all group members with that custom role, or remove those members from the group.

Remove a custom role from a group member

To remove a custom role from a group member, use the Group and Project Members API endpoint and pass an empty member_role_id value.

# to update a project membership
curl --request PUT --header "Content-Type: application/json" --header "Authorization: Bearer <your_access_token>" --data '{"member_role_id": "", "access_level": 10}' "https://gitlab.example.com/api/v4/projects/<project_id>/members/<user_id>"

# to update a group membership
curl --request PUT --header "Content-Type: application/json" --header "Authorization: Bearer <your_access_token>" --data '{"member_role_id": "", "access_level": 10}' "https://gitlab.example.com/api/v4/groups/<group_id>/members/<user_id>"

Remove a group member with a custom role from the group

  1. On the left sidebar, select Search or go to and find your group.
  2. Select Manage > Members.
  3. On the member row you want to remove, select the vertical ellipsis () and select Remove member.
  4. In the Remove member confirmation dialog, do not select any checkboxes.
  5. Select Remove member.

Delete the custom role

After you have made sure no group members have that custom role, delete the custom role.

  1. On the left sidebar, select Search or go to.
  2. GitLab.com only. Select Admin Area.
  3. Select Settings > Roles and Permissions.
  4. Select Custom Roles.
  5. In the Actions column, select Delete role () and confirm.

To delete a custom role, you can also use the API. To use the API, you must know the id of the custom role. If you do not know this id, find it by making an API request.

Known issues

  • If a user with a custom role is shared with a group or project, their custom role is not transferred over with them. The user has the regular Guest role in the new group or project.
  • You cannot use an Auditor user as a template for a custom role.