When you create a new CERN Drupal website you get a predefined list of roles already implemented with the website.
- Anonymous User
- Authenticated User
- CERN Registered
- CERN Shared
- HEP Trusted
- Verified External
- Unverified External
How to create a role and assign a user to it
Even though the sites come with predefined roles, website admins are able to create custom roles based on their needs. In order to create a new role:
- visit <website_url>/admin/people/roles
- Click on “Add role”
- Give a descriptive name to your role and save it.
- Now you have a new role.
How to give permissions to a role
After you have created the new role, you are able to give permissions to this role. There are pre-defined permissions for almost every basic functionality of your website. In order to grant a permission to a specific role:
- visit <website_url>/admin/people/permissions
- Check which roles should have the permissions
- Save the page
- Visit <website_url>/admin/people/permissions/<role_machine_name>
- Check permissions for this specific role
- Save the page
The difference between the two solution is that using the first solution, you can give multiple permissions to multiple roles and using the second solution, you can give multiple permission to one role.
CERN Drupal Websites also support CERN e-groups meaning that the admins of the websites can use this feature to assign roles to e-group. As a result, the admins of a website can grant access to a group of users, who belong to a specific e-group.
How to assign an e-group to a role
- Create a role using the process already described above
- Create an e-group on e-groups.cern.ch
- Visit <website_url>/admin/config/people/simplesamlphp_auth
- Click on “User Info and syncing” tab
- In the “Automatic role population from simpleSAMLphp attributes” field associate the role with the e-group by adding at the end of the string “|<e_group_machine_name>:egroups,=,<e_group_name>”
- Save Configuration
- Clear caches and re-open your browser.
- Now you are ready to add new members to your e-group which will have the permissions that you have assigned to the e-group.
Be extra careful in step 5 as you should assign the the machine name of the role and not the name of the role. In order to find the role you need to visit the role page, like the image below.
Sometimes it takes time for the e-group list to be updated (even a couple of hours) so if you have followed the steps and still the users do not have the permissions that they should, it’s probably due to the fact that the list is not updated yet. .
Also note that every time you add a new user, you should also clear the caches.
Use Case 1: Make another user a content editor
Let’s assume that I own a website and I want to make another user content editor to give him/her the ability to create new pages. Also, let’s assume that the new role is called “Page Editor” and the user’s e-mail is “firstname.lastname@example.org”.
The steps I follow in order to accomplish the above scenario are:
- Create a Role called “Page Editor”
- Visit the Permissions page of the created role and grant access to editing content for this role. Most of the times, when it’s about a content editor role, the permissions we grant are related to creation and editing of content, so be careful on what kind of permissions you grant.
- Create an e-group and bind it with the Role, following the steps already mentioned.
- Add the e-mail “email@example.com” in the group.
- Dont forget to clear the caches!
Use Case 2: Make another user an admin
This case is easier to achieve but you, as an admin, need to be sure about what you try to achieve. The admin role has access to every part of the website and that consequently means that the users that are granted this role, have the ability to modify every aspect of the website. As a result, you need to be extra careful before making the decision to grant this role to a user. If you have doubts about this user, it’s better if you create a new custom role, grant specific permissions for this role and add the user to the role following the steps we described in the previous use case.
If you are sure that you want to grant admin access to a user, then the only procedure that you need to follow is to add this user to the admin e-group. For this use case, let’s assume that the Drupal website that we own is called “accelerating-science.web.cern.ch” and that the user’s email that we want to make an admin is “firstname.lastname@example.org”. By default, every CERN Drupal website comes with an e-group called drupal-admins-name_of_the_website and contains all the admins of the created website. So in our case, the e-group will be called “drupal-admins-accelerating-science” and in order to make the user an admin, the only thing that we need to do is to add “email@example.com” to the “drupal-admins-accelerating-science” e-group.
To sum up:
- Visit e-groups.cern.ch
- Find the drupal-admins-accelerating-science e-group
- Add firstname.lastname@example.org to this e-group
- Done! Don’t forget to clear the caches.