MindAttic.Authentication/SPEC
MindAttic.Authentication — Product specification
The complete product, written down before it is built (owner, 2026-11-30, MAT-T360). Every epic, feature and story the finished product will have is listed here, built or not. The ticket tree mirrors this file one to one: every ID below is a ticket. Nothing gets built unless it is here, and anything taken out of here is closed wont-do in the tree.
RELEASE.mdsays which part of this the current milestone delivers.
1. Product definition
In docs/ECOSYSTEM.md this is a platform repo: it owns the sign-in concern, one hardened auth for every MindAttic app that has users.
MindAttic.Authentication is one hardened, Vault-backed sign-in engine shipped as a Razor Class Library (NuGet), so every MindAttic ASP.NET Core app (Gadfly, IdeaCms, IdiotProof, Prose, ThinkTank, Tutor) authenticates identically: Argon2id passwords with a Vault pepper, uniform responses with no enumeration oracle, TOTP MFA that cannot be bypassed, password change and reset, sessions that revoke promptly, opt-in organizations and invitations, and a full audit trail. It is built to OWASP ASVS L2 and NIST SP 800-63B AAL2 under a threat model that assumes a full database breach (SECURITY_SPEC.md, BIBLE.md). The finished product (11.0) adds startup-asserted wiring, an operator provisioning CLI, a signed reproducible package and phishing-resistant passkeys.
2. Scope boundary
2.1 In the product
- Password storage: Argon2id + pepper, PHC strings, rehash on login, fail-closed crypto floors.
- Secrets: read fail-closed from
MindAttic:Vault:Security:*; provisioned by an operator CLI, never by the app. - Brute-force defence: persistent backoff per account and IP, timing floor, normalized keys, hashed audit.
- MFA: TOTP with replay protection, single-use recovery codes, forced enrollment and step-up, then passkeys.
- Password lifecycle: NIST policy, change, enumeration-safe email reset, security alert emails.
- Host integration: one-call wiring,
/_ma-authendpoints, presentation-only components, session revalidation, bootstrap admin, user administration, settings on the Vault tab, Debug-only dev bypass. - Organizations, memberships and invitations (opt-in), with a host hook that can refuse an acceptance.
- Release hygiene: whole-number majors in
C:\LocalNuGet, docs current, consumers ticketed per release.
2.2 Never in the product
- Cross-app SSO or an identity provider. Each app is its own trust boundary (M.AUTH-LAW-6).
- A secrets store. The library reads secrets; the Vault and the provisioning CLI hold and create them.
- Moving the crypto primitives into MindAttic.Cryptography. Tried and reverted; they stay here.
- Hard deletes. Accounts are disabled, never deleted (HOUSE-LAW-2).
- Upgrading consumers from this repo. Each consumer moves to a new major under its own ticket in its own repo.
- Open-ended sweeps ("run the full suite and fix everything", "/simplify", "exhaustive bughunt"); real bugs are filed one at a time.
- SMS one-time codes, social login, third-party credential validation. SMS is below AAL2 and the docs ask for none of them.
3. Users and roles
- U: an end user of a consuming app; signs in, enrolls MFA, changes or resets a password, manages passkeys.
- Admin: an elevated operator inside a consuming app; manages users, organizations and invitations.
- Host: the developer of a consuming app; wires the library in, brands the components, supplies hooks.
- Op: the owner as secrets and deployment operator; provisions the Vault secrets, publishes the package.
4. Requirements
Status is built (closed ticket, with evidence) or MS-n: the milestone in §7 that delivers it. Every unbuilt story is approved and prioritised in build order; the planner splits a story into tasks when the queue reaches it.
E1. Password storage and secrets — M.AUTH-T70 — built
F1.1 Hashing and secrets — M.AUTH-T71 — built
- S1.1.1 Argon2id with pepper — M.AUTH-T72 — built. As a Host, passwords are stored as Argon2id plus a Vault pepper so a DB-only breach yields nothing crackable. Evidence:
Argon2idPasswordHasherTests,PhcArgon2Tests. - S1.1.2 Self-describing rehashable hashes — M.AUTH-T73 — built. Evidence:
PhcArgon2Tests,UserStore.ApplyRehash. - S1.1.3 Fail-closed crypto floors — M.AUTH-T74 — built. Evidence:
AuthCryptoOptionsTests. - S1.1.4 Fail-closed secrets — M.AUTH-T75 — built. Evidence:
ConfigAuthSecretsTests,ConfigAuthSecretsLinuxNamingTests.
E2. Brute force and enumeration defence — M.AUTH-T76 — built
F2.1 Lockout, timing and audit — M.AUTH-T77 — built
- S2.1.1 Persistent exponential backoff — M.AUTH-T78 — built. Evidence:
AccountLockoutServiceTests; b540f45, 27c777a, 029aebf. - S2.1.2 No enumeration oracle — M.AUTH-T79 — built. Evidence:
TimingFloorTests. - S2.1.3 Normalized account keys — M.AUTH-T80 — built. Evidence:
AuthKeysTests; dc8ee71. - S2.1.4 Hashed audit trail — M.AUTH-T81 — built. Evidence:
AuthAuditWriterTests.
E3. Two-step verification — M.AUTH-T82 — built
F3.1 TOTP and recovery codes — M.AUTH-T83 — built
- S3.1.1 TOTP validation — M.AUTH-T84 — built. Evidence:
TotpServiceTests; 6c65463. - S3.1.2 MFA enrollment — M.AUTH-T85 — built (its tests land in MS-28: M.AUTH-T4).
- S3.1.3 QR enrollment — M.AUTH-T58 — built. Evidence: f86c0f3.
- S3.1.4 Recovery codes redeem once — M.AUTH-T86 — built. Evidence: 8850db8, 56e0bcd.
- S3.1.5 MFA required for admins — M.AUTH-T87 — built (its tests land in MS-28: M.AUTH-T9).
E4. Password lifecycle — M.AUTH-T88 — built
F4.1 Policy, change and reset — M.AUTH-T89 — built
- S4.1.1 NIST password policy — M.AUTH-T90 — built. Evidence:
PasswordPolicyTests. - S4.1.2 Change password — M.AUTH-T91 — built (its tests land in MS-28: M.AUTH-T5).
- S4.1.3 Enumeration-safe reset — M.AUTH-T92 — built. Evidence:
PasswordResetServiceTests. - S4.1.4 Reset email delivery — M.AUTH-T93 — built. Evidence:
SmtpAuthEmailSenderTests. - S4.1.5 Security alert emails — M.AUTH-T94 — built. Evidence:
SecurityAlertTests.
E5. Host integration — M.AUTH-T95 — built
F5.1 Wiring, endpoints and administration — M.AUTH-T96 — built
- S5.1.1 Login with MFA step-up — M.AUTH-T97 — built. Evidence:
AuthenticationServiceTests,AuthenticationServiceConfirmMfaTests. - S5.1.2 One-call host wiring — M.AUTH-T98 — built (its tests land in MS-28: M.AUTH-T8, T9).
- S5.1.3 Revoked sessions end — M.AUTH-T99 — built (its tests land in MS-28: M.AUTH-T6, T7).
- S5.1.4 First-run admin bootstrap — M.AUTH-T100 — built (its tests land in MS-28: M.AUTH-T11).
- S5.1.5 User administration — M.AUTH-T101 — built. Evidence:
UserAdminServiceTests. - S5.1.6 Open-redirect-safe return URLs — M.AUTH-T102 — built. Evidence:
UrlSafetyTests. - S5.1.7 Settings on the Vault tab — M.AUTH-T103 — built. Evidence: 2b87874,
LampAuthSettingsTests. - S5.1.8 Dev-only sign-in bypass — M.AUTH-T104 — built (its tests land in MS-28: M.AUTH-T10).
E6. Organizations and invitations — M.AUTH-T105 — built
F6.1 Memberships and invitations — M.AUTH-T106 — built
- S6.1.1 Organizations and memberships — M.AUTH-T34 — built. Evidence: d352e6e (8.0.0),
OrganizationServiceTests. - S6.1.2 Email invitations — M.AUTH-T35 — built. Evidence: bd39fe2 (9.0.0),
InvitationServiceTests.
E7. Security invariants under test — M.AUTH-T51 — MS-28
F7.1 Account rules proven — M.AUTH-T53 — MS-28
- Task: MFA enrollment tests — M.AUTH-T4. Given an expired or tampered pending secret or a bad code, when ConfirmAsync runs, then MFA stays disabled.
- Task: Password change tests — M.AUTH-T5. Given a wrong current password, then nothing changes and it is audited; given success, then history is written and the stamp rotates.
- Task: Bootstrap and user-store tests — M.AUTH-T11. Given any existing user, then seeding is a no-op; given no bootstrap token, then it throws.
F7.2 Revoked sessions stay revoked — M.AUTH-T54 — MS-28
- Task: Cookie validation tests — M.AUTH-T6. Given a mismatched stamp or idle timeout, then the cookie is rejected.
- Task: Blazor revalidation tests — M.AUTH-T7. Given a revoked or expired session, then the circuit loses access.
F7.3 HTTP surface proven — M.AUTH-T55 — MS-28
- Task:
/_ma-authendpoint tests — M.AUTH-T8. Given an off-site returnUrl or no antiforgery token, then it is refused. - Task: Forced-step and CSP middleware tests — M.AUTH-T9. Given MustEnrollMfa, then the user is redirected; excluded paths never are.
- Task: Dev bypass gate tests — M.AUTH-T10. Given a non-loopback IP or a non-Development host, then nothing happens.
E8. Every host signs in safely — M.AUTH-T52 — MS-28
F8.1 Invitation accept gate — M.AUTH-T56 — MS-28
- Task: Host can refuse an acceptance — M.AUTH-T38. As a Host (Gadfly), I refuse an acceptance with my own message when a plan has no free seat. Given the gate refuses, then the invitee sees that message and the invitation stays open.
F8.2 Docs match the library — M.AUTH-T57 — MS-28
- Task: Docs match the code — M.AUTH-T17. Given the docs, then
docs/overview.mdand BIBLE §6/§7 describe 9.x, the test coverage and the consumers.
F8.3 MFA setup works in every host — M.AUTH-T66 — MS-28
- Task: One plain code field — M.AUTH-T63. As a U, I type my authenticator code into one field that works in every host. Given a host with no scoped CSS and Chrome autofill, then the code is entered and confirmed.
F8.4 Polish and release 9.x — M.AUTH-T67 — MS-28
- Task: Pack the proven release — M.AUTH-T68. Given the milestone's tasks are done, then the package is in
C:\LocalNuGetand the docs name its version. - Task: Owner sign-off, no partial rows — M.AUTH-T69 (owner hands-on).
E9. Fail-closed wiring and provisioning — M.AUTH-T107 — MS-134
F9.1 Middleware order asserted — M.AUTH-T108 — MS-134
- S9.1.1 Startup filter checks order — M.AUTH-T109. As a Host, a misordered pipeline throws at startup naming the fix. Given
UseMindAtticAuthenticationafter the endpoints, when the host starts, then it throws.
F9.2 Secrets provisioned into Vault — M.AUTH-T110 — MS-134
- S9.2.1 Provision auth secrets — M.AUTH-T111. As an Op, I create the pepper, KEK and reset key with a CSPRNG into the Vault (RFC 0001). Given existing secrets, then it refuses without
--rotate. - S9.2.2 Rotate the pepper — M.AUTH-T112. Given users hashed under pepper v1, when I rotate to v2, then they still sign in and rehash to v2.
F9.3 Signed reproducible package — M.AUTH-T113 — MS-134
- S9.3.1 Deterministic signed pack — M.AUTH-T114. Given two packs of one commit, then they are byte-identical and the signature verifies.
F9.4 Polish and release 10.0 — M.AUTH-T115 — MS-134
- S9.4.1 Release 10.0 — M.AUTH-T116. Given the epic is done, then 10.0 is in
C:\LocalNuGet, docs are current, each consumer repo has an upgrade ticket, and the owner signs off.
E10. Phishing-resistant MFA — M.AUTH-T117 — MS-135
F10.1 Passkeys as a second factor — M.AUTH-T118 — MS-135
- S10.1.1 Register a passkey — M.AUTH-T119. As a U, I register a WebAuthn passkey after re-entering my password. Given the ceremony completes, then only the public key is stored, audited and alerted.
- S10.1.2 Sign in with a passkey — M.AUTH-T120. Given a passkey signed on the right origin, then the session gets
amr=mfa; on another origin (an AITM relay), then it fails and is audited. - S10.1.3 Manage passkeys — M.AUTH-T121. Given my last factor, when I remove it, then it is refused;
RequirePasskeyForAdminforces admins to enroll one.
F10.2 Polish and release 11.0 — M.AUTH-T122 — MS-135
- S10.2.1 Release 11.0 — M.AUTH-T123. Given the epic is done, then 11.0 is published, the AITM residual is marked closed in SECURITY_SPEC, consumers are ticketed, and the owner signs in with a passkey.
Added by MAT-T477 (owner stories and cross-repo links)
- S M.AUTH-T124 Invitation email sets a password (feature M.AUTH-T56, MS-28): Tutor's TUT-T258 requires it.
- E M.AUTH-T125 Sign in with an institution (MS-135; priority 500)
- F M.AUTH-T126 SAML and OIDC single sign-on / S M.AUTH-T127 Institution single sign-on: Gadfly's GAD-T943 requires it; the 11.0 polish M.AUTH-T122 waits for it.
5. Non-functional requirements
- Platform: net10.0 Razor Class Library; hosts are ASP.NET Core with EF Core owning the
authschema. - Security bar: OWASP ASVS L2 (L3 where feasible), NIST SP 800-63B AAL2; uniform response and timing on every outcome; fail-closed on missing secrets, weak crypto settings and missing production Data Protection keys.
- Data: no raw password, secret, recovery code or reset token is ever stored or logged; audit account keys are hashed; accounts are disabled, not deleted.
- Versioning: whole-number majors only (VERSIONING.md); a release is done when every consumer references it and builds (M.AUTH-LAW-7), through their own tickets.
6. Interfaces and dependencies
Platform it relies on (docs/ECOSYSTEM.md): MindAttic.Vault (auth secrets: pepper, KEK and reset-signing key are provisioned into and read from Vault), MindAttic.Agency, MindAttic.Tickets. Consumers: IdeaCms, Tutor, Gadfly and every app with users.
- Uses: MindAttic.Vault (secrets and the settings tab), Konscious Argon2, BCrypt (legacy hashes only), EF Core, SMTP through the Vault
Notificationsemail settings. - Used by: Gadfly (organizations, invitations, accept gate), IdeaCms, IdiotProof, Prose, ThinkTank, Tutor.
- Contract:
AddMindAtticAuthentication/UseMindAtticAuthentication/MapMindAtticAuthEndpoints, theIAuthDataContextschema, theMa*components' typed parameters,IAuthEmailSender, and (MS-28) the invitation accept gate. See API.md, INTEGRATION.md, CONFIGURATION.md.
7. Release sequence
- MS-28: Authentication proven and stable (active). Epics E7 M.AUTH-T51 and E8 M.AUTH-T52: every built path is test-proven, the accept gate exists, the MFA page works in every host, docs are current; ends with F8.4.
- MS-134: Authentication 10, fail-closed wiring and provisioning. Epic E9 M.AUTH-T107; ends with F9.4.
- MS-135: Authentication 11, passkeys (the finished product). Epic E10 M.AUTH-T117; ends with F10.2.
8. Change log
| Date | Change to scope | Ticket |
|---|---|---|
| 2026-11-30 | Specification written from the BIBLE, SECURITY_SPEC, USER_STORIES, RFC 0001, code and ticket history. The middleware-order filter, provisioning CLI and signed pack (the USER_STORIES priority backlog) became MS-134; WebAuthn (US-D4) became MS-135, the finished product. | MAT-T383 |
| 2026-11-30 | MAT-T462 single-source pass: 6 renamed, 0 buckets, 14 requires added, 1 platform re-point (provisioning named as Vault-backed) | MAT-T466 |
| 2026-11-30 | MAT-T477 owner story for Tutor, Gadfly | MAT-T477 |