ADR-030 — Password policy per tenant
Date: 2026-12-01
Status: Accepted
Extends: ADR-023 (hierarchical settings),
ADR-029 (the strictest of the account's tenants decides).
Origin: Azure DevOps US 10336; plan docs/plans/2026-12-01-feat-politica-de-senha-por-tenant-plano.md.
Context
The password policy was one rule for the whole deployment: IdentityOptions.Password in code (12 characters, a digit,
a lower-case and an upper-case letter and a symbol), enforced by the Identity PasswordValidator<TUser>. The SPA
mirrored it by hand (PASSWORD_MIN_LENGTH = 12), so changing one side silently left the other behind. Customers have
different security requirements, and one tenant's stricter rule could not be met without imposing it on every tenant.
A password belongs to the account, and the account opens every tenant it is a member of. The screen that sets a
password from an emailed link is anonymous: there is no session and no ambient tenant when the password is chosen.
Three paths write a password — the invitation/reset link, the administrator's reset and the bootstrap administrator in
IdentitySeeder — and all three go through UserManager's password validators.
Decision
Five settings in PasswordPolicySettingDefinitions (group auth.password, levels Global and Tenant,
EditableBy = System):
| Key | Default | Constraint |
|---|---|---|
Password.MinimumLength | 12 | 8–128 |
Password.RequireDigit | true | — |
Password.RequireLowercase | true | — |
Password.RequireUppercase | true | — |
Password.RequireNonAlphanumeric | true | — |
The defaults are the previous rule, so a deployment without overrides behaves as before. There is no configuration layer: the values were in code, as the lockout's were (ADR-029).
- A fixed floor in code (
PasswordPolicy.Floor): 8 characters and no required character class. It is the definition's minimum, so a write below it is refused, and the policy provider raises every value it reads to it, so no layer can hand out a weaker policy. Length is what protects a password; composition rules are left to each tenant (NIST SP 800-63B § 5.1.1). - An account follows the strictest policy among its active tenants, each dimension on its own: the longest minimum
length, and a character class is required when any active tenant requires it (
PasswordPolicy.Strictest). An account without an active membership — including one not yet saved — followsGlobal. The password must work in every tenant the account opens, and the anonymous link has no tenant to follow. The memberships are the same query the lockout uses (AccountTenants). - One validator for every path:
TenantPasswordPolicyValidatorreplaces Identity'sPasswordValidator<AppUser>and returns the sameIdentityErrorcodes, read from the account's policy.IdentityOptions.Passwordis no longer set. - The SPA reads the policy, never mirrors it:
POST {Bff}/auth/password/policyanswers the policy of the account a valid link token belongs to (the token is verified, not consumed; an invalid one gets the sameAuth.InvalidPasswordTokenas setting the password), andGET {Bff}/users/{id}/password-policy(Users.Update, within the caller's reach) answers it for the administrator's reset. An account owned by an external provider is refused on both, as the writes refuse it. An administrator's reset that the policy refuses answersUser.PasswordPolicyonnewPassword. The two anonymous routes of the link share a per-address rate limit (auth-password-link): the token is the barrier, the limit caps how often one address makes them verify tokens and read policies. - Sign-in does not check the password against the policy. The policy applies when a password is set or changed. A password that met the rule when it was chosen keeps signing in after the rule tightens or the account joins a stricter tenant, until it is changed.
Consequences
- The system administrator sets each customer's policy in Configurações do sistema with no new screen. The tenant's administrator sees the value and its origin but cannot change it.
- A strict tenant tightens the rule for the other tenants of the accounts it shares. An administrator of tenant B may see, on a reset, requirements that come from tenant A; only the numbers are shown, never the tenant.
- A tightened policy does not reach existing passwords until they are changed. Asking for the change at sign-in is a later story.
- A consumer that configured
IdentityOptions.Passwordoutside the template loses that effect; the settings replace it. - The bootstrap administrator is created before it has a membership, so it follows
Global. AGlobaloverride stricter thanIdentity:Admin:Passwordmakes the first start fail; an existing administrator is not re-validated. - A policy change reaches another replica within the settings' 30-second L1 cache.
Alternatives considered
- The tenant being signed in to decides. The anonymous link has no tenant, so setting the password would follow one rule and signing in another. The password is the account's and opens every tenant.
- Check the password at sign-in and ask for a change. Asking inside the flow needs a change ticket after the second factor, a persisted flag, session and token endpoints and a new screen; sending the user to the reset e-mail is simpler but turns a tightened policy into a wave of forced resets. Left for a later story.
- The floor is today's rule (tenants can only tighten). Rejected: the story exists for customers with different requirements, and some ask for a gentler composition rule with a longer password.
- Keep Identity's validator with
IdentityOptions.Passwordset to the floor and add a second validator. Two validators report the same failure twice, and two places would hold a rule. - Moving the policy to the DevPack. The strictest rule reads the template's
TenantUser. The definitions and the validator are candidates to move up once a second consumer needs them.