Authentication & Login¶
This page covers how users sign in to CosMO and the account-security controls you manage as an administrator: the login method, the password policy, forced password change, and two-factor authentication (2FA / TOTP).
Most of this is configured from the CosMO configuration tool on the Authentication tab — you do not need to edit configuration files by hand.
Login methods¶
CosMO supports three login methods, selected by cosmo.login-method (the Login Method dropdown on the Authentication tab):
| Method | Who verifies the password | Setup |
|---|---|---|
local | CosMO's own user database | Default. Password policy, forced change, and 2FA all apply. |
saml | Your SAML Identity Provider (SSO) | See the SSO callback/redirect notes in Reverse Proxy Setup and the SAML signing certificate in HTTPS & TLS Certificates. |
oidc | Your OpenID Connect provider (SSO) | Same SSO notes as above. |
Local-only features
The password policy, forced password change, and two-factor authentication described below apply to local authentication only. With SAML or OIDC the Identity Provider owns credentials and multi-factor, so CosMO defers to it.
Password policy¶
The password policy enforces password rules for local accounts, on every password create, change, and admin reset. It is off by default (no rules), so you opt in to exactly the controls your organisation requires.
Configuring it¶
On the Authentication tab's Local card, use the Strictness slider to pick a preset — Off, Low, Medium, High, or Strict. The slider fills in the individual rules; open Advanced settings to fine-tune any single rule (which moves the slider to Custom). Only the individual rules are saved.
The rules¶
All rules live under cosmo.password-policy.* and default to off (0 or false):
| Setting | Default | Meaning |
|---|---|---|
min-length | 0 | Minimum length (0 = no minimum). |
max-length | 0 | Maximum length (0 = no maximum). See the cap note below. |
max-sequential-run | 0 | Reject a run of more than N sequential characters (e.g. 12345). |
max-repeat-run | 0 | Reject the same character repeated more than N times (e.g. aaaa). |
required-uppercase | 0 | Minimum uppercase letters. |
required-digits | 0 | Minimum digits. |
required-special | 0 | Minimum special characters. |
reject-username | false | Reject a password that contains the username. |
reject-application-name | false | Reject a password that contains "Cosmo". |
reject-common-passwords | false | Reject common/dictionary passwords (with leetspeak folding, so p@ssw0rd ≈ password). |
common-passwords-file | (unset) | Absolute path to an extra blocklist file, merged with the built-in list. |
history-count | 0 | Block reuse of the last N passwords. |
max-age-days | 0 | Expire passwords older than N days; login is refused until the password is reset. |
force-change-on-reset | false | Force a change on next login after an admin sets a password (see below). |
The same policy expressed as configuration properties:
cosmo:
password-policy:
min-length: 12
max-length: 72
required-uppercase: 1
required-digits: 1
reject-username: true
reject-common-passwords: true
history-count: 5
max-age-days: 180
Maximum length is capped at 72
Passwords are limited to 72 characters. CosMO rejects anything longer rather than silently shortening it, so set max-length no higher than 72 (64 is the minimum useful maximum per policy).
Forced password change on first login¶
When force-change-on-reset is enabled, any password an administrator issues or resets (and the initial bootstrap admin password) is valid only until the user's next sign-in: on first login the user is sent straight to a change password screen and cannot use the rest of the application until they choose a new one.
Off by default
This is disabled unless you turn on cosmo.password-policy.force-change-on-reset (the Force password change after an admin sets a password toggle on the Local card). It applies to admin-issued and admin-reset passwords, and to the first-run admin account.
Two-factor authentication (TOTP)¶
CosMO can require a second factor at login for local accounts, using a time-based one-time password (TOTP) from an authenticator app (Google Authenticator, Microsoft Authenticator, Authy, etc.).
Enabling it¶
Set cosmo.mfa.mode (the Two-factor authentication (TOTP) dropdown):
| Mode | Behaviour |
|---|---|
disabled | No second factor. (Default.) |
optional | Users may enrol from their profile. |
required | Every local user must enrol before they can use the app. |
How a user enrols¶
- The user opens their Profile and starts 2FA setup.
- CosMO shows a QR code (and a manual key). The user scans it into their authenticator app.
- The user types the current 6-digit code to confirm, and 2FA is now active.
In required mode, a user who has not yet enrolled is guided into enrollment before they can reach the rest of the app.
How login works with 2FA¶
After the username and password step, an enrolled user is prompted for the current 6-digit code. Only then is the session granted.
Three attempts, then back to the login error page
After 3 incorrect codes the pending sign-in is discarded and the user is returned to the login-error page to start over.
'Remember me' is disabled for 2FA users
So the second factor can never be skipped, any existing remember-me cookie is cancelled when a user enrols, and remember-me is not offered to enrolled users.
Managing 2FA¶
- A user can disable their own 2FA from their profile — unless the mode is
required, in which case self-disable is blocked. - An administrator can Reset 2FA for a user (from the user's admin screen) if they lose their device; the user then re-enrolls.
Secrets are stored encrypted
Each user's TOTP secret is encrypted at rest using the encryption master secret — see Security & Secrets.
Common problems¶
| Symptom | Likely cause |
|---|---|
| A strong password is rejected as "too long" | It exceeds the 72-character limit — shorten it, or lower max-length. |
| Password rules aren't enforced | The login method is not local (SAML/OIDC own credentials), or every rule is still at its default off value. |
| "Reject common passwords" misses an obvious weak password | It isn't in the built-in list — add a common-passwords-file with your own entries. |
| Users are unexpectedly forced to change their password | force-change-on-reset is on and their password was admin-issued/reset. |
| A user is locked out of 2FA (lost phone) | Use the admin Reset 2FA action so they can re-enrol. |
| A user can't turn off their own 2FA | The mode is required; self-disable is intentionally blocked. |