[GlitchTip] HEIMDALL-D0 — Remove blocking admin role query from camera access #281

Closed
opened 2026-11-07 10:25:27 +01:00 by arnaud.dartois · 0 comments
Owner

Résumé

Make camera access authorization fully asynchronous when checking whether a user is an administrator, preserving existing authorization outcomes and honoring cancellation.

Pourquoi

The synchronous role lookup blocks a thread during async authorization and database access, reducing request throughput and surfacing a blocking-call warning.

État actuel et preuves

  • Implemented: CameraAccessService currently checks Identity UserRoles synchronously in IsAdmin.
  • Local evidence: GlitchTip HEIMDALL-D0 (#7447) reports the blocking call; no fix or validation has been recorded yet.
  • CI evidence: none for this issue yet.
  • Production/hardware evidence: the warning is application-side; no deployment validation is required.

Écart à résoudre

The private IsAdmin method calls synchronous EF Any over UserRoles, and callers execute it inside asynchronous camera/site access methods.

Analyse

Use an asynchronous EF Core existence query with the caller's CancellationToken. Keep the same user-id guard, role predicate, and authorization result. Verify translation and behavior with PostgreSQL-backed relational tests; no schema changes are expected.

Plan de travail

  1. Search open and closed Gitea issues for this warning and reuse a matching ticket where present.
  2. Update CameraAccessService and focused tests to propagate cancellation and preserve admin/non-admin behavior.
  3. Run focused infrastructure tests, PostgreSQL relational validation, and persistence policy checks.
  4. Run the mandatory disposable Compose acceptance against changed source with unique credentials, project resources, and image tags; record and verify cleanup.
  5. Update this issue with evidence and link the pull request.

Critères d’acceptation

  • CameraAccessService performs admin role lookup asynchronously through EF Core and passes the operation CancellationToken.
  • Existing admin and non-admin camera/site authorization outcomes are unchanged.
  • PostgreSQL-backed test passed: CameraAccessAdminPostgresTests.Admin_role_lookup_and_camera_authorization_translate_and_preserve_results verifies admin and viewer camera/site outcomes through Npgsql.
  • Focused Infrastructure tests passed (26/26); Web ResourceAccessTests passed (14/14); scripts/ci/check-efcore-usage.py passed.
  • Disposable Compose acceptance passed from changed source: project heimdall-7447-accept-20261107170319-23018, Central /healthz returned 200 and unauthenticated /api/events returned 401. Cleanup verified project containers, volumes, and network absent, and exact local image tag heimdall:heimdall-7447-accept-20261107170319-23018-central absent; shared base images retained.
  • Pull request links this issue; close only after all criteria are complete.

Hors périmètre / dépendances

No role model, schema, API contract, or deployment change. Requires local Docker and PostgreSQL test support; no production camera or customer data is needed.

Maquette

Aucune maquette requise : this is an infrastructure authorization fix.

Liens

  • GlitchTip: HEIMDALL-D0 (#7447)
  • Focused skill: skills/camera-access-async-admin-check/SKILL.md

Validation evidence (2026-11-07)

The async role lookup and cancellation token are covered by the PostgreSQL test above. The source-based disposable Compose recipe used only synthetic generated credentials, isolated ports, project volumes/network and a unique image tag; teardown and exact-tag image removal were verified. Pull request: #286
Commit: d86171f

## Résumé Make camera access authorization fully asynchronous when checking whether a user is an administrator, preserving existing authorization outcomes and honoring cancellation. ## Pourquoi The synchronous role lookup blocks a thread during async authorization and database access, reducing request throughput and surfacing a blocking-call warning. ## État actuel et preuves - Implemented: CameraAccessService currently checks Identity UserRoles synchronously in IsAdmin. - Local evidence: GlitchTip HEIMDALL-D0 (#7447) reports the blocking call; no fix or validation has been recorded yet. - CI evidence: none for this issue yet. - Production/hardware evidence: the warning is application-side; no deployment validation is required. ## Écart à résoudre The private IsAdmin method calls synchronous EF Any over UserRoles, and callers execute it inside asynchronous camera/site access methods. ## Analyse Use an asynchronous EF Core existence query with the caller's CancellationToken. Keep the same user-id guard, role predicate, and authorization result. Verify translation and behavior with PostgreSQL-backed relational tests; no schema changes are expected. ## Plan de travail 1. Search open and closed Gitea issues for this warning and reuse a matching ticket where present. 2. Update CameraAccessService and focused tests to propagate cancellation and preserve admin/non-admin behavior. 3. Run focused infrastructure tests, PostgreSQL relational validation, and persistence policy checks. 4. Run the mandatory disposable Compose acceptance against changed source with unique credentials, project resources, and image tags; record and verify cleanup. 5. Update this issue with evidence and link the pull request. ## Critères d’acceptation - [x] CameraAccessService performs admin role lookup asynchronously through EF Core and passes the operation CancellationToken. - [x] Existing admin and non-admin camera/site authorization outcomes are unchanged. - [x] PostgreSQL-backed test passed: `CameraAccessAdminPostgresTests.Admin_role_lookup_and_camera_authorization_translate_and_preserve_results` verifies admin and viewer camera/site outcomes through Npgsql. - [x] Focused Infrastructure tests passed (26/26); Web `ResourceAccessTests` passed (14/14); `scripts/ci/check-efcore-usage.py` passed. - [x] Disposable Compose acceptance passed from changed source: project `heimdall-7447-accept-20261107170319-23018`, Central `/healthz` returned 200 and unauthenticated `/api/events` returned 401. Cleanup verified project containers, volumes, and network absent, and exact local image tag `heimdall:heimdall-7447-accept-20261107170319-23018-central` absent; shared base images retained. - [x] Pull request links this issue; close only after all criteria are complete. ## Hors périmètre / dépendances No role model, schema, API contract, or deployment change. Requires local Docker and PostgreSQL test support; no production camera or customer data is needed. ## Maquette Aucune maquette requise : this is an infrastructure authorization fix. ## Liens - GlitchTip: HEIMDALL-D0 (#7447) - Focused skill: skills/camera-access-async-admin-check/SKILL.md ## Validation evidence (2026-11-07) The async role lookup and cancellation token are covered by the PostgreSQL test above. The source-based disposable Compose recipe used only synthetic generated credentials, isolated ports, project volumes/network and a unique image tag; teardown and exact-tag image removal were verified. Pull request: https://sources.tordais.cc/arnaud.dartois/Heimdall/pulls/286 Commit: `d86171f`
arnaud.dartois added the area:autharea:camerapriority:P2type:bug labels 2026-11-07 10:25:41 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: arnaud.dartois/Heimdall#281