Skip to content

feat(capabilities): implement capability model and backend authorization enforcement (CYN-53) - #36

Merged
SiddharthaGF merged 3 commits into
mainfrom
pablosantiago/cyn-53-implement-capability-model-and-backend-authorization-enforcement
Aug 6, 2026
Merged

feat(capabilities): implement capability model and backend authorization enforcement (CYN-53)#36
SiddharthaGF merged 3 commits into
mainfrom
pablosantiago/cyn-53-implement-capability-model-and-backend-authorization-enforcement

Conversation

@SiddharthaGF

Copy link
Copy Markdown
Owner

Summary

  • Add hospital-scoped capability assignments (CapabilityAssignment entity, CapabilityCodes Stage 2 catalog, per-tenant composite index) with grant/revoke/list workflows
  • Enforce capabilities at both authorization boundaries: endpoint-level RequireCapabilityAttribute/authorization filter (with access.denied audit) and domain-boundary ICapabilityGuard across all JADNC resource services and Application services (deny-by-default)
  • Expose GET /api/me/capabilities (typed effective-capability response mirroring the enforced resolution) and GET/POST /api/capabilities, DELETE /api/capabilities/{actorId}/{capability} (capabilities.read / capabilities.write), documented in OpenAPI
  • Seed demo capability grants via CurrentActorOverride actor context so seeding, HTTP, and domain enforcement share one actor-resolution path

Test plan

  • dotnet cake --target=Check (format + lint + tests) — 325 tests, 0 warnings
  • Allowed read 200; denied / write-while-read-only / no-actor → 403 with access.denied audit
  • Cross-tenant: assignment in one hospital never authorizes access in another
  • Revocation takes effect on the next request; HTTP grant → list → revoke workflow round-trips
  • 19 capability unit tests (effective resolver caching/scoping, guard, assignment service) + 9 Postgres-backed enforcement tests

Linear:

…oundaries (CYN-53)

Add hospital-scoped capability assignments and enforce them at every
authorization boundary:
- Add CapabilityAssignment domain entity and CapabilityCodes catalog
- Gate all JADNC resource services and Application services with
  ICapabilityGuard (deny-by-default)
- Add CapabilityAuthorizationFilter/RequireCapabilityAttribute for
  endpoint-level enforcement with access.denied audit
- Add api/capabilities (list/grant/revoke, capabilities.read/write) and
  api/me/capabilities (effective set mirror) endpoints
- Seed demo capability grants via CurrentActorOverride actor context
- Add 19 capability unit tests and 9 Postgres-backed enforcement tests;
  extend OpenApiContractTests for the new endpoints
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Neon branch ready.

…tities

- Introduced [NoResource] attribute to CapabilityAssignment, ClinicalDocument, Encounter, and Patient classes to prevent them from being treated as resources in the JsonApiDotNetCore framework.
- Added necessary using directives for JsonApiDotNetCore.Resources.Annotations in the respective files.
- Added support for legacy database baselining in the EnsureDatabaseSchemaAsync method to manage migrations for databases created before EF migrations existed.
- Introduced capability_assignments table creation logic to align with legacy schema requirements.
- Updated .editorconfig to exclude generated migration code from analyzer checks.
- Added Microsoft.EntityFrameworkCore.Design package for improved EF tooling.
- Modified test setup to exclude the EF migrations history table during schema resets, ensuring migration stamps remain valid.
@SiddharthaGF
SiddharthaGF temporarily deployed to pablosantiago/cyn-53-implement-capability-model-and-backend-authorization-enforcement - cynara-api PR #36 August 6, 2026 05:29 — with Render Destroyed
@SiddharthaGF
SiddharthaGF merged commit fb7fcb2 into main Aug 6, 2026
4 checks passed
@SiddharthaGF
SiddharthaGF deleted the pablosantiago/cyn-53-implement-capability-model-and-backend-authorization-enforcement branch August 6, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant