Application Passwords logo
An editor's Application passwords tab listing three passwords: "Inventory sync" limited to the REST API and to requests from 198.51.100.0/24, never expiring and never used; "AI assistant (MCP)" limited to MCP and three permissions, expiring in 30 days, last used from 192.0.2.77; and "GitHub Actions deploy" limited to JSON:API, last used minutes ago from 203.0.113.24. Each row shows its identifier, who created it and a Revoke button.
The Add application password form: a name ("Mobile app"), an expiry of 30 days, the APIs it may use (JSON:API ticked out of REST, JSON:API, GraphQL and MCP), the roles it may act with, and "Only the permissions I choose" selected, with the site's permissions grouped by module below.
The page shown once after creating a password: the new password in a read-only field with a Copy button, a message that it will not be shown again, and how to use it with the user name or as a bearer token.
The settings page: accept passwords wherever HTTP Basic is accepted, accept them as bearer tokens, optionally only on routes in a route group, HTTPS only; and the route groups table for REST, JSON:API, GraphQL and MCP with the route name patterns each covers and how many routes match now.

This project is not covered by Drupal’s security advisory policy.

Application Passwords gives each user named, revocable passwords for the site's APIs, so scripts, CI jobs, site-to-site sync and AI agents (MCP clients) never need the account password. Each password can be limited to some APIs, roles and permissions, can expire, and can be revoked on its own.

Status: Stable, for production use. 1.0.0 is the first release. Please report anything that does not behave as described in the issue queue.

Why

Core's HTTP Basic Authentication takes the account password itself on every API request. One leaked script then exposes the whole account, and the only way to cut it off is to change the password everywhere. WordPress has shipped application passwords in core since 5.6; this module brings the same idea to Drupal, and adds scopes, expiry, IP limits and flood control, which WordPress's version does not have.

Features

Passwords

  • Many named passwords per account: 25 by default, up to 1,000. Expired passwords do not count against the limit.
  • Generated by the server, shown once with a copy button, and never retrievable. Only a SHA-256 hash of the 190-bit random secret is stored; the form that shows it is never cached, and the response is sent with Cache-Control: no-store.
  • A fixed format: dap_ followed by 50 letters and digits, with a checksum. Typos and junk are refused without a database query, and a secret scanner can be given a pattern that finds leaked passwords with few false positives.
  • Optional expiry, from presets or a date, with 90 days preselected, and an optional site-wide maximum lifetime. Responses to an expiring password carry an Application-Password-Expires header, so clients can rotate in time.
  • Optional IP limits: IPv4 or IPv6 addresses and CIDR ranges.
  • Passwords cannot be edited. To change a scope, create a new password, so a leaked password can never be widened.

Scopes

  • Route groups: REST (including Views REST exports), JSON:API, GraphQL and MCP are included, and you can add your own. Each group accepts passwords where the route lists them, always, or never, so a site can, for example, keep passwords off JSON:API entirely.
  • Roles: limit a password to some of its owner's roles. The request then runs with only those roles (plus Authenticated user), so role checks, Views role access and role-based node grants see the scope.
  • Permissions: limit a password to a list of its owner's permissions. Through core's Access Policy API, the request gets only what is both on the list and held by the owner now, applied after every other access policy so no module can add to it.
  • Caches are kept apart for each scope: the user, user.roles and user.is_super_user cache contexts include the scope, so limited passwords still use the Dynamic Page Cache without seeing another scope's pages.

Authentication

  • HTTP Basic username:password, with the account name or email address, as WordPress clients send it, or Authorization: Bearer, as MCP clients send it.
  • Works alongside core's HTTP Basic Authentication: it claims only passwords in its own format, and leaves account passwords and other bearer tokens (OAuth, JWT) to their own modules.
  • HTTPS only, unless you explicitly allow plain HTTP for local development.
  • Flood control per IP address: 50 failed attempts an hour by default, then 429 Too Many Requests. A valid password is checked first and is never turned away, whatever else the same address sent.
  • Never accepted on login, logout, password reset, registration, account edit or cancel, this module's own pages, or any admin route. Under an application password, no account's password or email address can be changed, and no account can be deleted or cancelled.
  • Refusals come in the client's own format, such as a JSON:API error document, with a WWW-Authenticate challenge.

Revocation

  • Revoke one password or all of them from the account's Application passwords tab, from the overview of every password, from Drush, or from the client itself with DELETE /application-passwords/introspect.
  • All of an account's passwords are revoked when it is blocked or deleted, and by default when its password changes. A login that only rehashes the stored password is not counted as a change.
  • A revoked or expired password fails on the very next request, even with the page cache, Dynamic Page Cache and the entity cache warm.
  • The overview's search finds a leaked password in whatever text it turned up in, such as an .env line, an Authorization header, JSON, a URL or a log line, and redirects with only the password's identifier in the address, never the secret.

Passwords for other accounts

  • Creating a password for another account, such as a service account, needs its own restricted permission.
  • Such a password gets only the permissions and roles that the creator and the account both hold, at creation and again on every request: what the creator loses, the password loses on the next request.
  • Its creator is recorded and shown in every list, the account is emailed (configurable), the password stops working while the creator lacks the permission, and it is revoked when the creator's account is blocked or deleted.

For operators and developers

  • Last-used time, for successful requests only, and last-used IP address with a retention period (30 days by default; 0 never stores it).
  • Status report checks: plain HTTP, the client address and scheme Drupal sees (with a warning when proxy headers arrive but reverse proxy settings are off), the routes accepting passwords in each group, and active and never-used counts.
  • Drush commands for deploy scripts: application-passwords:create (prints only the password, or JSON with --json), application-passwords:list and application-passwords:revoke, with the aliases ap-create, ap-list and ap-revoke.
  • An introspection endpoint, GET /application-passwords/introspect, that describes the password a request used: its name, owner, creator, scopes, the roles it acts with and its expiry.
  • Events on create, successful authentication (subscribers can refuse it), failure and revocation, and a provenance API that tells MCP tools and audit logging which application acted, apart from the user.
  • Log messages name passwords by ID only, never by user name, label, email or IP address, and each refusal of a genuine password is logged at most once a day.

Requirements

  • Drupal 11.3 or later, or Drupal 12.
  • PHP 8.3 or later.
  • The core User module only; no contributed modules. Optional: Drush 13 or later, for the commands.
  • The site served over HTTPS. Behind a proxy or CDN, Drupal's reverse proxy settings must be configured; the README explains them.
  • Tested on MySQL, MariaDB, PostgreSQL and SQLite.

Installation

Install with Composer, then enable the module:

composer require drupal/application_passwords
drush en application_passwords

Nothing changes until you grant Use application passwords to the roles that need API access. Only those accounts can create passwords, and only HTTPS requests are accepted.

Configuration and permissions

Settings are at Administration » Configuration » People » Application passwords (/admin/config/people/application-passwords). Each account has an Application passwords tab (/user/{user}/application-passwords), and the overview of every password is at People » Application passwords (/admin/people/application-passwords).

  • Use application passwords (not restricted): create, view and revoke application passwords for your own account, and authenticate with them. Passwords work only while their owner holds this permission, so removing it switches them off without deleting them.
  • Create application passwords for other accounts (restricted): see another account's passwords and create passwords that act as that account, limited as described above. Such a password also reaches what belongs to the account: its content, through "own" permissions both hold, and its account settings and profile, which it can read, email address included, and edit, apart from the password and email address. Grant it only to people trusted with those accounts.
  • View and revoke any application password (restricted): the overview of every account's passwords, with its leaked-password search, and revoking any of them. It does not allow creating passwords for other accounts.
  • Administer application passwords (restricted): the settings page only: where passwords are accepted, their limits, flood control and retention.

Using it safely

Give each client its own password, limited to the route group it calls and to the permissions it needs; an MCP agent, for example, gets the MCP group and the permissions its tools use. Set the reverse proxy settings behind a proxy or CDN: without them HTTPS may not be recognized, IP limits cannot work, and every client's failures share one flood budget. The status report shows what Drupal sees. A connection that stays open, such as an MCP stream, keeps the authentication it opened with until it closes.

Known limitations

  • A scope does not reach access decided by user ID: a password still acts as its owner, so it reaches the owner's own content through "own" permissions in its scope, and the owner's account settings and profile. It also does not reach code that loads the user entity and reads its roles directly, or Group memberships under a role-only scope; use a permission list to shut other access scopes off.
  • A cache ID that custom code builds from the user ID by hand, instead of through cache contexts, is not kept apart for each scope.
  • Routes with no response format, such as MCP Server's endpoint, get Drupal's HTML error page with a 401 or 403. The status code and the WWW-Authenticate header are correct.
  • The GraphQL and MCP route groups are set up from those modules' route names, but have not been tested with GraphQL, MCP Server or the MCP module installed. Another module whose authentication provider claims every HTTP Basic or bearer header at a higher priority can take the request first.
  • Flood control counts per IP address, so clients behind one shared address share one budget for failed attempts.
  • Blocking an account revokes its passwords for good; unblocking it restores nothing.
  • The password table's Views data has no query access handler: a view of it shows every account's rows to whoever may see the view, so give such a view a restricted permission as its access.
  • WordPress's "authorize application" redirect flow is deliberately not implemented: it returns the password in a URL query string.

Roadmap

Under consideration, depending on feedback: an email reminder before a password expires, and a rotate command. Today, create a new password and then revoke the old one.

Similar projects

Compared in November 2026, from each project's code and documentation.

  • Core's HTTP Basic Authentication takes the account password on every request. Use it when a client must sign in as the account itself. This module works alongside it. In benchmarks, it authenticated a request in under a quarter of a millisecond, where core's password check (bcrypt at PHP 8.4's default cost) took over 200 milliseconds.
  • Key auth gives each user one API key, stored in plain text on the account and sent in a header or the query string, with no expiry, scope or rate limit. Choose it if one key per user is all you need; this module stores only hashes, allows many passwords per user and adds scopes, expiry and flood control.
  • Simple OAuth (OAuth2) & OpenID Connect is the right choice for third-party apps that users authorize through a consent screen, and for MCP clients that support OAuth discovery. It needs client registration, keys and token refresh. This module covers what that makes heavy: a script, a CI job, an agent you run yourself, or a client that only takes a header. Both can be installed together.
  • WordPress's application passwords are the model for this module, and clients that send HTTP Basic username:application-password work unchanged. WordPress's version has no scopes, expiry or failure rate limiting, and checks a password against every hash the user has instead of one indexed lookup.

Support and maintenance

Report bugs and ask for features in the issue queue. Each release has notes describing what changed.

This project is not covered by Drupal's security advisory policy. Until it is, security issues are handled in the public issue queue and fixed in ordinary releases.

A read-only mirror is on GitHub at DanePete/drupal-application-passwords. Development, issues and releases stay on drupal.org.

Maintainer

Created and maintained by deadnorth (Dead North).

Project information

Releases