Passkey login for Moodle 4.5 and 5.x

Moodle has passkeys only as a second factor. Our free auth_passkeys lets people log in with a passkey instead of their password, on Moodle 4.5 LTS to 5.3.

Drawing of a grey door whose keyhole sits inside a large cobalt fingerprint, a hand reaching for it and an old key lying on the floor.

Short answer: Moodle supports passkeys only as a second factor after the password, through its multi-factor authentication. Our free plugin, auth_passkeys, lets people log in with a passkey instead: they pick the Passkey button on the login page and confirm with their fingerprint, face, screen lock or security key. Their password keeps working. It supports Moodle 4.5 LTS to 5.3.

This is the thirty-sixth plugin in our series: one plugin for each Moodle plugin type, each one teaching DevLMS Studio, our AI plugin builder, how that type works. Logging in with a passkey has been an open request in Moodle’s tracker since 2022 (MDL-76125, 25 votes and 39 watchers when we checked). Moodle Marketplace, which replaced the plugins directory, lists no authentication plugin for “passkey” or “webauthn”. The one earlier attempt we found on GitHub, VanThe812/auth_passkey, is an alpha for 4.5 without tests.

What it does

  • A Passkey button on the login page. The browser shows the passkeys saved for the site. No username to type.
  • A Passkeys page under Preferences to add passkeys with a name, see when each was added and last used, and remove them.
  • Admins can remove a lost phone’s passkey for someone. They cannot add one for anyone, and nobody can add one while an admin is “logged in as” them.
  • The same checks as the password login. Suspended, unconfirmed and locked accounts are refused. Failed passkey logins count towards the lockout and show in the logs.
  • Nothing extra to install. It uses the WebAuthn library Moodle already ships for its multi-factor login.

What it does not do

By default only accounts with Moodle passwords can use passkeys (manual accounts and email signup). On an LDAP, SAML or OAuth 2 account, a passkey would let people in without asking that system, even after it disabled them, so admins have to choose that knowingly. It does not replace multi-factor authentication: MFA still asks for its factors after a passkey login. It does not suggest passkeys in the username field, and it needs the site on https, because browsers allow passkeys nowhere else. Changing the site’s host name makes existing passkeys stop working.

The code is on GitHub.

How a Moodle authentication plugin works

From Moodle 5.3’s login code (the same in 4.5):

  1. An authentication plugin can check a typed password, or add a button to the login page that leads to its own way of logging in.
  2. A plugin that logs people in without a password has to repeat the checks core makes (suspended, locked, confirmed, which method the account uses) before it starts the session, then run the same steps as the login page.
  3. Passkeys are checked with public keys: the site keeps only the public half, and the phone or computer signs a fresh challenge each time.
  4. We test it with a software passkey that signs real responses, 33 unit tests on Moodle 4.5 and 5.3, and a browser test in Chrome that adds a passkey, logs out and logs back in with it. The browser tests caught two bugs the unit tests could not, both now fixed.

Need a plugin like this for your own Moodle?

Describe it in DevLMS Studio and watch it built and tested in a real Moodle, or ask our team for a fixed price.

Open DevLMS Studio