OAuth2, OAuth providers, SAML, SQRL, Windows SSO, passkeys, two-factor, passwordless, session cookies, password hashing, autologin, multitenancy, Nextcloud, Oracle, Zitadel and the Let's Encrypt setup, each in the same order, checked against the code. Corrected where the code had moved on: passwordless codes are 10 characters for 15 minutes and are not counted by the lockout; an OAuth2 login merges an existing account only when enabled and the email is verified; the Admin Panel sections are under People; the two-factor entry is hidden only on Sandstorm and for OAuth2 accounts; the Zitadel example no longer turns on B2C; Rocket.Chat's claim is preferred_username. Thanks to xet7 !
6.9 KiB
Two-Factor Authentication (TOTP)
What it is
Opt-in per-user two-factor authentication (TOTP - the same standard used by
Google Authenticator, Authy, etc.), added for
#3058. After the password,
signing in also asks for a 6-digit code from an authenticator app, so a
stolen password alone is not enough. An administrator can also make it
compulsory with REQUIRE_2FA. It is built on Meteor's official accounts-2fa
package - WeKan only draws the QR code and enable/disable buttons; the secret
generation and code verification is done by Meteor itself.
Read more
- Time-based one-time password (TOTP) at Wikipedia
- Multi-factor authentication at Wikipedia
- Meteor accounts-2fa documentation
- Passkeys, Passwordless and Accounts Lockout
How to use it
Click your avatar/name → Two-Factor Authentication, in the member menu (Member Settings).
┌ (your avatar) ▾ ─────────────┐
│ Change Settings │
│ Change Color │
│ Notifications │
│ Change Font │
│ Change Avatar │
│ Change Password │
│ ▸ Two-Factor Authentication │ <- here
│ Hidden boards, Passkeys, ... │
│ Change Language │
└─────────────────────────────────┘
┌ Two-Factor Authentication ───────────┐
│ Scan this QR code with your │
│ authenticator app: │
│ ┌───────────┐ │
│ │ ▓▓ ▓ ▓▓ │ │
│ │ ▓ ▓▓▓▓ ▓ │ or enter manually: │
│ │ ▓▓ ▓ ▓▓ │ ABCD-EFGH-1234 │
│ └───────────┘ │
│ Code: [______] [Confirm] [Cancel] │
└─────────────────────────────────────────┘
Turn it on
- Open your member menu and click Two-Factor Authentication.
- Click Enable Two-Factor Authentication to start activation.
- Scan the shown QR code with an authenticator app (Google Authenticator, Authy, etc.), or type the manual-entry secret shown under it ("Or enter this code manually") into the app by hand.
- Enter the 6-digit code the app now generates into Enter your 6-digit authentication code and click Confirm and Enable.
- Once confirmed, the popup shows "Two-factor authentication is enabled for your account." and a Disable Two-Factor Authentication button; from then on, logging in also asks for a 6-digit code.
Sign in with it: after the user name and password, the sign-in page asks Enter your 6-digit authentication code; type it and click Verify.
Make it compulsory (administrator): Admin Panel / People / Login, or the
environment variable REQUIRE_2FA = off (default), admins or all. A
covered account without 2FA can still sign in, but sees only "Set up
two-factor authentication" until it has done so, and cannot switch it off
again while it is required.
Prerequisites:
- An authenticator app on a phone/device able to scan a QR code or accept a manual TOTP secret.
- Not available when logged in via Sandstorm, and the menu entry is hidden
for OAuth2/OIDC accounts (Google/Azure/OIDC/etc. logins manage their own
second factor, if any). Meteor asks for the code only on a password
login, so for LDAP, SAML and CAS accounts it has no effect either, and
REQUIRE_2FAcovers only accounts that sign in with a WeKan password. (The old text said the entry appears only for password accounts; the code hides it only on Sandstorm and forauthenticationMethodoauth2.)
How the numbers are calculated
- 6 digits: the code fields accept at most 6 digits; the code is the
standard TOTP value, computed and checked by
accounts-2fafrom the shared secret and the current time. REQUIRE_2FA:offunless the value is exactlyadminsorall(case-insensitive);adminscovers accounts withisAdmin: true(models/lib/twoFactorRequirement.js).- An account "has 2FA" when
services.twoFactorAuthenticationhas asecretandtype: 'otp', the same testaccounts-2famakes.
How it works in WeKan
- client/components/users/userHeader.jade
and
userHeader.js- thetwoFactorAuthPopup, callingAccounts.generate2faActivationQrCode,Accounts.enableUser2faandAccounts.disableUser2fa. - client/components/main/layouts.jade -
the second sign-in step, shown when a password login answers
no-2fa-codeorinvalid-2fa-code(imports/lib/twoFactorAuthLoginDecision.js, wired in config/accounts.js). - models/lib/twoFactorRequirement.js and server/requireTwoFactor.js - the compulsory mode: until enrolled, every method but signing in/out and the 2FA methods is refused, publications but the login page's are empty, HTTP routes and the REST API do not accept the login; client/components/users/twoFactorRequired.jade shows only the set-up.
- Tests: tests/requireTwoFactor.test.cjs, tests/twoFactorLoginState.test.cjs, tests/twoFactorLockoutErrors.test.cjs.
Integration tests
See local login protocol tests for example identities, actual request/response checks, failure cases and deployment limitations.
Commits
- Every method and publication, the 2FA ones too, pass audit-argument-checks
- Compulsory two-factor authentication with REQUIRE_2FA
- Fix Firefox password login submit replay
- Hide two-factor challenges nobody asked for
- Document Two-Factor Authentication
- Add native TOTP two-factor authentication via Meteor's accounts-2fa