Heimdall Gitea / Detect CI scope (push) Successful in 6s
Heimdall Gitea / Build and tests (push) Successful in 19m19s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan server image (push) Successful in 6m13s
Heimdall Gitea / Build and scan agent image (push) Successful in 14m44s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 1m48s
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Successful in 19m9s
Heimdall Gitea / CI policy (push) Successful in 10s
Merge pull request #138 Co-authored-by: Arnaud Dartois <admin@tordais.cc>
5.5 KiB
5.5 KiB
name, description
| name | description |
|---|---|
| heimdall-identity | Implement and review Heimdall account, password, session, email confirmation, lockout, and two-factor authentication flows built on ASP.NET Core Identity. |
Heimdall Identity workflow
Read AGENTS.md, the AUTH-BOOTSTRAP entry in todo.md, and the Identity wiring in Infrastructure/DependencyInjection.cs and Web/Program.cs before changing authentication.
- Identity owns password hashing, normalized account lookup, role membership, lockout, authenticator tokens, and email/password tokens. Do not duplicate password or token cryptography in Heimdall.
- Keep ASP.NET Core Identity packages and types inside Infrastructure. Domain must not reference Identity; Application uses
IIdentityAccountServiceandIdentityAccountonly. Put Identity EF entities (IdentityAppUser,IdentityAppRole) andUserManager/RoleManageradapters in Infrastructure. Keep user-related Domain relationships keyed byGuid UserId; configure their foreign keys to the Infrastructure user entity. - When creating an Identity user, copy the generated
SecurityStampback into the application account before building the first session/JWT. Cover bootstrap and regular user creation with a relational session validation test. - Moving Identity model classes without changing tables should produce an explicit empty EF migration and a snapshot containing the Infrastructure entity types. Verify migration compatibility against PostgreSQL before release.
- Keep bootstrap one-time and PostgreSQL-serializable. Anonymous registration stays disabled after bootstrap; role and account creation failures must not be reported as success.
- Keep public login/reset responses generic so they do not reveal account existence, lockout state, or Identity policy details. Logs must not contain emails, passwords, tokens, authenticator keys, recovery codes, or Identity error descriptions; log safe error codes only when needed.
- Rotate
SecurityStampafter password changes/resets, email or role changes, lock/unlock, and 2FA changes. Verify existing cookies, JWTs, and refresh tokens are rejected after the change. - Enroll an authenticator in two steps: create/show the setup key while 2FA remains disabled; renew the user's access token and cookie after Identity rotates the security stamp; verify a TOTP code before enabling 2FA and creating one-time recovery codes. Persist only hashes of recovery codes, redeem each atomically once, and clear them when 2FA is disabled.
- Check every
IdentityResultbefore proceeding. Avoid partial account creation; clean up the created user if role assignment fails. - Keep first-account provisioning on
/setup→/api/auth/bootstrap-admin; later accounts and role assignment use/users→/api/users. Do not reintroduce a second Admin-registration endpoint. - Keep the three supported role names seeded by Identity. Seed their default permission claims once using a durable role-claim marker; the Admin permission set stays immutable. Manage Supervisor/Viewer permission claims from
/admin/claims, then include those persisted claims in login, refresh, cookie, and 2FA auth responses. - When role membership or role permissions change, rotate every affected user's security stamp and record the acting administrator in the audit log. Protect last-admin demotion, deletion, and lockout based on unlocked Admin accounts.
- Apply
[Collection("E2E")]on each concrete Playwright test class deriving fromE2ETestBase; xUnit does not reliably inherit the PostgreSQL fixture attribute from its abstract base. - Configure Identity options explicitly and review changes to password, unique email, confirmed email, lockout, cookie, token-provider, and Data Protection behavior.
- CI installs Chromium through the Playwright CLI already copied beside the Release E2E test assembly (
node tests/Heimdall.E2E.Tests/bin/Release/net10.0/.playwright/package/cli.js install --with-deps chromium). This keeps browser tooling on the test project's locked Playwright dependency graph and avoids an independently restored C# script project. - Keep PostgreSQL-specific transaction and concurrency guarantees in Infrastructure. Use relational integration tests for bootstrap races, recovery-code redemption, session revocation, and migration compatibility.
- For behavior changes, update FR/EN resources and UI/API contracts, add focused tests, update
todo.md, and run the disposable Compose acceptance recipe with unique credentials, ports, volumes, project name, and network. - Acceptance must exercise bootstrap through the setup UI, user lifecycle and role editing through
/users, permission editing through/admin/claims, and verify the resulting JWT/API allow and deny decisions. Check that stale sessions fail after a role/permission change and that the last usable Admin cannot be demoted, deleted, or locked. - Record a project-unique tag for each source-built Central acceptance image and install an EXIT cleanup trap before build/start. After scoped Compose teardown, verify zero containers/volumes/networks and remove/verify absence of each exact local tag even on failure. Keep shared upstream base images, preserve test exit status, report cleanup failures, and avoid
--rmi allor broad image-prune commands.
Useful official references: ASP.NET Core Identity configuration, Two-factor authentication, and Data Protection.