Role Mapping

The role mapping feature allows you to map the Drupal roles and permissions to the users based on the attributes received from the OAuth or OpenID Connect Provider. This feature allows the assignment of roles to the user in Drupal after performing a successful SSO.

Steps to map roles from OAuth provider to Drupal site

  • Once you have configured the OAuth or OIDC Provider successfully, you can click on the Test Configuration button to verify if the configurations are correct or not.
  • If all the configurations are correct, you will receive a list of attributes from OAuth or OIDC Provider.
  • After you have received the attribute list, navigate to the Attribute & Role Mapping tab.
  • To map the attributes of a provider, click on their respective Edit link.

Drupal OAuth Client - Role mapping - Click Edit Link

Basic Role Mapping

The Basic Role Mapping is the process of assigning roles to the users when they are created on the Drupal site after performing Single Sign On. The user can be assigned one of the predefined roles like Administrator, Authenticated user, and Content editor.

Configure Basic Role Mapping

  • Scroll down to the Role Mapping section.
  • Check the Enable Role Mapping checkbox. It is mandatory for role mapping.
  • Now, select the default role for the new user from the Select the default role for new users dropdown. This role will be assigned to the newly created user on their first login.
  • Click on the Save Configuration button.

Drupal OAuth Client - Basic Role mapping

Custom Role Mapping

Custom Role mapping feature allows assigning roles to a user, based on the user information or attributes received from the OAuth or OIDC Provider. To configure the Custom Role Mapping, we can also add a few more roles to the Drupal site.

Configure Custom Role Mapping

  • After following the steps for basic configuration, scroll down to the Role Attributes section.
  • Select the Drupal Role from the dropdown that you want to assign to a user on the basis of their role coming from the OAuth provider.
  • Now, enter the OAuth provider role in the OAuth Server/Provider Role text field. Users can enter more than one role by separating with ;(semicolone).

Drupal OAuth Client - Custom Role mapping section

  • Users can add more than one Drupal Role by clicking + (Plus) in front of the Role Attributes text.

Drupal OAuth Client - Custom Role mapping - Add Roles

Let’s see how Role Mapping works:

  • Open an incognito window / new browser. Navigate to the Drupal site login page and log in with the provider name link.
  • Navigate to People → Roles. Click on the List tab. You can find the list of mapped roles.

Drupal OAuth Client - Custom Role mapping - how it works