We have quite some special behavior for uid #1. This tends to confuse the user, and will do so even more now we have an admin role in core. Do all the special cases we designed around uid #1 really make sense?
Problems with special casing uid 1
- People are confused whether they should be sharing credentials of this user (bad) or just using a user with the Administrator role.
- The lack of permission check on user 1 means that uid 1 can take actions on a site even if they do not have a role that grants them the permission. This makes it hard to completely disable unwanted features on a site unless you block uid 1 and never use it.
- The lack of permission check on user 1 makes them a particularly valuable account for an attacker to take over in some way. Any time there is a focus point for an attack it makes the system weaker.
Potential problems with *not* special casing
If someone is playing around and removes all roles or removes all permissions from all their admin users it could be possible to have no users with administrator permissions on a site. While is is a problem it is easily solved with a FAQ page and some database instructions just like we do with WSOD.
Proposed resolution
The special behaviour of uid 1 should be removed. Instead there is an admin role that always has all permissions. All special treatment for uid 1 should be converted to proper permissions, and as the admin role always has all permissions, any member of this role would have the same access as uid 1 has now. The following steps need to be taken:
- Create an admin role by default, just like the anonymous and authenticated role, in the user module, and also make it undeletable, and make it the admin role.
- Remove the is_admin_role setting from the GUI (simplifies the GUI).
- Assign user 1 the admin role on install. (do this in the user module, not the chosen install profile).
- When deleting or disabling a user, or removing the admin role from a user, check that there is at least one user left with the admin role, otherwise cancel the action.
User interface changes
The setting of which role is the admin role can be removed from admin/config/people/accounts.
API changes
When deleting or disabling a user, or removing the admin role from a user, check that there is at least one user left with the admin role, otherwise cancel the action. Also remove any special behaviour for uid 1. Test using an admin user with a uid greater than 1.
Beta phase evaluation
Issue category | Task because the exceptions made for uid 1 are not needed anymore (we have the admin role now) and the exceptions circumvent the permissions model that is one of Drupal's strong points. (the current situation confuses users and constitutes a security risk). |
---|---|
Issue priority | Major because uid 1 special exceptions are used in many places. The proposed fix does not introduce any new behaviour or features, but brings the admin user in line with standard Drupal role and permission based behaviour. |
Prioritized changes | The main goal of this issue is usability and security. It also reduces fragility. |
Disruption | Wether or not the issue is disruptive for core/contributed and custom modules/themes is up for discussion: All existing special treatments of uid 1 will still work as long as the first admin user still has uid 1. The change could be gradually rolled out across core/contrib modules, by rewriting tests to use a test user with a different uid. This would not be very disruptive. But it will require changes across many subsystems in order to make core consistent with this new behaviour. Also existing Drupal 8 beta sites would need an upgrade to create or lock down an admin user role. |