An administrator account on a Drupal site can change content, install code through Composer-managed workflows, alter configuration and read user data. Locking those accounts down is one of the cheapest security jobs you can do, and it needs no new infrastructure. This guide covers the account side of Drupal security: credentials, sign-in methods, roles, cleanup, sessions, tokens and what to do when something leaks.
Start with unique credentials and a password manager
Every person who administers the site needs their own account. Shared logins make it impossible to tell who did what, and they make offboarding messy because changing one password affects everyone.
Each account should have a long, random password that is used nowhere else. A password manager makes this practical: it generates and stores the password so nobody has to remember or reuse one. Reused passwords are the usual route from a breach on an unrelated service to your Drupal back end.
- Store credentials in a team password manager, not in spreadsheets, chat messages or tickets.
- Give each administrator a personal account with a personal email address, not a role mailbox that several people read.
- Avoid obvious usernames such as admin for the account with the most power.
- Treat the first account created during installation (user 1) with special care. In Drupal it bypasses permission checks, so keep its use to emergencies and protect it as strongly as anything on the site.
Core also includes flood control, which limits repeated failed login attempts. Contributed modules such as Password Policy and Login Security add stricter rules, if your team wants them. Check each module’s project page on drupal.org and its compatibility with your Drupal version before installing it.
Add two-factor authentication or single sign-on
A strong password still fails if it is phished or leaked. A second factor means a stolen password alone is not enough to sign in.
Drupal core does not ship two-factor authentication as a built-in feature, so you add it with contributed modules. Common choices include the Two-factor Authentication (TFA) module, which supports authenticator-app codes and other methods through plugins, and modules that integrate with outside identity providers. What is available and how well it fits your version of Drupal depends on the module, so read its documentation and release notes first.
If your organisation already runs a central identity provider, single sign-on is often the better route. Contributed modules exist for SAML and for OpenID Connect, which let staff sign in with their company account. That way, disabling someone at the identity provider removes their access in one place, and the provider’s own two-factor rules apply.
- Decide whether you want two-factor on Drupal itself or SSO through your identity provider.
- Test the setup on a staging copy first, including the recovery path for a lost phone.
- Enforce it for every account that can edit configuration or install modules, then extend it to editors.
- Keep one tested break-glass procedure, documented offline, in case the identity provider or second factor is unavailable.
Whatever you choose, serve the whole site over HTTPS, so credentials and session cookies are never sent in the clear.
Apply least privilege to roles
Most people who log in do not need the Administrator role. Drupal’s role and permission system lets you grant only what each job requires, so use it.
Open the permissions page and review what each role can do. Create specific roles, such as content editor, site builder or user manager, and assign permissions to them. Then give people the narrowest role that lets them work.
- Keep the number of full administrators as small as you can.
- Watch permissions that Drupal flags with a warning to give only to trusted roles, because they can be abused to gain more access.
- Separate content work from site-building work. Editors rarely need access to configuration, modules or the permissions screen.
- Use the permission to administer users sparingly. Someone who can edit accounts and roles can often promote themselves.
Drupal also has a setting that restricts who can administer certain sensitive permissions. Review it, so that a delegated user manager cannot hand out the most powerful roles.
Review and remove old users on a schedule
Dormant accounts are a quiet risk. A former contractor’s login is often still active months after the project ends, protected by a password nobody has rotated.
The People page in the Drupal admin lets you filter users by role and status and see when each person last accessed the site. Make a review part of your routine, for example when you apply updates.
- List everyone with an elevated role and confirm each one still needs it.
- Block accounts that belong to people who have left or no longer need access.
- Remove elevated roles from accounts that are still needed but only for ordinary tasks.
- Choose the cancellation method with care. Blocking an account keeps its content attributed to it, while deleting it can reassign or remove content depending on the option you pick.
If you manage the site with Drush, its user commands can block accounts, add or remove roles and generate one-time login links, which is handy for audits and offboarding. Check the commands available on your version with Drush’s built-in help.
Tighten sessions and API tokens
A logged-in session is as good as a password until it expires. Session lifetime in Drupal is controlled by PHP and by settings in your site’s services configuration, so check what your hosting and configuration allow. Shorter lifetimes for administrators reduce the window in which a stolen session cookie is useful. Contributed modules for automatic logout or session limits can help where the defaults are too loose.
Then consider every other way into the site:
- If you enable core web services such as REST or JSON:API, check which authentication each endpoint accepts and which permissions the authenticated user holds.
- Create dedicated service accounts for integrations, with only the permissions the integration needs, never a personal administrator login.
- Keep API keys and secrets out of the codebase and the database export. Environment variables or a secrets mechanism such as the Key module keep them out of version control.
- Rotate keys when a developer or vendor leaves, and remove integrations you no longer use.
Keep core and contributed modules current too. The Drupal Security Team publishes advisories at drupal.org/security, and some of them concern access bypass or authentication flaws that no password policy can fix. For broader background on authentication risks, the OWASP Top Ten is a useful reference.
What to do if admin credentials leak
Act on the assumption that the credential is already in use. Speed matters more than a perfect investigation.
- Block the affected account, or change its password, and make sure its active sessions end.
- Reset passwords for any other account that shared that password, and for anyone with the same email and password pairing elsewhere.
- Review the People page for accounts you do not recognise, and for roles that were changed recently.
- Check the site’s logs, including the Recent log messages report if the database logging module is enabled, plus your server logs, for unexpected logins and configuration changes.
- Inspect installed modules and themes for anything you did not add, and compare the codebase against your version control.
- Rotate API keys, service account passwords and any secrets the compromised account could reach, including database credentials if server access is in doubt.
- Restore from a clean backup if you find signs of tampering, then fix the cause before you reopen access.
Afterwards, add the missing control, whether that is two-factor, a narrower role or a shorter session, so the same route stays closed. The official Drupal documentation covers user management and security configuration in more depth for your version.
Frequently asked questions
Does Drupal have built-in two-factor authentication?
Not in core. You add it with contributed modules, such as the Two-factor Authentication (TFA) module, or by connecting Drupal to an identity provider through a SAML or OpenID Connect module. Check each module’s documentation for the methods it supports.
How many people should have the Administrator role?
As few as the site can run on. Most editors and managers can work with a custom role that holds only the permissions they use, which limits the damage if one account is compromised.
Is blocking a user safer than deleting them?
Blocking is usually the first step, because it stops the login while keeping the account’s content and history intact. Delete only after you have decided what should happen to the content that account created.