Heimdall Gitea / Detect CI scope (push) Successful in 6s
Heimdall Gitea / Build and tests (push) Successful in 26m21s
Heimdall Gitea / Build and scan agent image (push) Successful in 6m32s
Heimdall Gitea / Build and scan server image (push) Successful in 8m59s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 1m37s
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Successful in 26m10s
Heimdall Gitea / Publish signed main release (push) Canceled after 42m57s
Heimdall Gitea / CI policy (push) Failing after 2s
## Résumé Réduit les écritures de `LastUsedAt` à une mise à jour atomique EF Core par clé et par minute, tout en transmettant l’annulation HTTP aux requêtes de validation. Ajoute une vérification PostgreSQL concurrente et le workflow projet dans `skills/api-key-last-used-throttle/SKILL.md`. ## Tickets Refs #200, #201, #202, #203, #205. Les tickets restent ouverts jusqu’à la vérification post-déploiement GlitchTip requise par leurs critères; les événements examinés étaient en environnement Development et ne démontrent pas une régression en production. ## Vérifications observées - `dotnet test tests/Heimdall.Infrastructure.Tests/Heimdall.Infrastructure.Tests.csproj --no-restore --filter FullyQualifiedName~ApiKeyLastUsedPostgresTests` — 1 réussi. - `dotnet test tests/Heimdall.Web.Tests/Heimdall.Web.Tests.csproj --no-restore --filter FullyQualifiedName~ApiKeyIdentityTests` — 1 réussi. - `python3 scripts/ci/check-efcore-usage.py` — réussi. - Compose jetable construit depuis le commit, projet isolé `heimdall-api-key-20261109100145-12450`, image `heimdall:heimdall-api-key-20261109100145-12450-acceptance`; `/healthz` et `/api/auth/bootstrap-status` HTTP 200. Après teardown, aucune ressource Compose du projet ne subsiste et le tag exact est absent. L’image PostgreSQL et les images amont sont conservées. ## Limite d’acceptation Le Compose vérifie le démarrage source et les routes HTTP de santé/bootstrap; le changement de persistance et la concurrence sont exercés par le test d’intégration PostgreSQL. Reviewed-on: #313 Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2.1 KiB
2.1 KiB
name, description
| name | description |
|---|---|
| api-key-last-used-throttle | Preserve Heimdall API-key authentication while limiting LastUsedAt persistence to one atomic EF Core update per minute. |
API-key activity timestamp
ApiKeyAuthenticationHandler authenticates an agent API key for every protected request. LastUsedAt is an operator-facing activity indicator; it does not need request-level precision. Keep API-key validation, agent binding, authorization claims, and expiry checks on every request, while avoiding a database write for every heartbeat or telemetry call.
Implementation
- Pass
HttpContext.RequestAbortedto each database read and write in the authentication handler. - Update
LastUsedAtwith EF CoreExecuteUpdateAsync, using a database-side predicate that permits the write only when the timestamp is null or at least one minute old. The predicate and update must be one SQL statement so concurrent requests using the same key collapse to one write. - Do not call
SaveChangesAsyncfor this timestamp. The handler has no other pending changes, and the tracked API-key entity is only needed for validation and claims. - Keep the timestamp semantics visible to operators: after a burst of requests, it reports recent use with up to one minute of delay.
Acceptance
- A PostgreSQL relational test verifies that a null timestamp is written, requests inside the one-minute window do not rewrite it, an expired window refreshes it, and concurrent requests produce no duplicate update within the window.
- API-key authentication tests verify valid, expired, unbound, and invalid keys retain their existing outcomes and claims.
- Run the CI EF Core persistence policy and the focused Infrastructure/Web test suites.
- Run the disposable Compose recipe from
skills/compose-disposable-recipe/SKILL.mdwith unique credentials, project name, ports, volumes, and local image tag. Verify authentication behavior, then verify that project resources and the exact locally built tag are absent after teardown. - Link the change to Gitea GlitchTip issues #200, #201, #202, #203, and #205. Record the actual local/CI/Compose results and keep post-deployment GlitchTip evidence distinct.