Skip to content

API security: authorization scenario test suite and SMART authz demo - #19

Draft
degoke wants to merge 4 commits into
mainfrom
degoke/authz-test-suite-7adb
Draft

degoke wants to merge 4 commits into
mainfrom
degoke/authz-test-suite-7adb

Conversation

@degoke

@degoke degoke commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

Implements issue #8 Phases 1–4: a CI-enforced authorization semantics test kit, patient scope hardening, SMART HTTP integration helpers, and a runnable demo.

Closes #8

Changes

Phase 1 — pkg/testkit/authztest/

  • 46 documented authorization scenarios in CI (exceeds ≥30 acceptance criteria)
  • Covers REST CRUD, patient compartment, search/_include filtering, views, AI tools, sync device push, module install, SMART token semantics (exp/nbf/iss/aud), and scope-vs-policy conflicts
  • Reusable fixtures (RestrictedClinician, TenantAdmin, BackendServicePrincipal, policies) and RunAll runner

Phase 2 — SMART semantics

  • smart.ScopePolicyAuthChecker — wires SMART scope-derived RequiredPermissions into HTTP auth decisions
  • smart.DefaultConfiguration.well-known/smart-configuration metadata shape for hosts
  • Additional tests: nbf-in-future rejection, policy-deny-despite-scope

Phase 3 — Patient scope hardening

  • CheckPatientScope documented as production compartment enforcement (no longer marked stub)
  • Bundle transaction/batch entries now enforce patient scope on embedded resource bodies
  • Search bundle post-filter for _include/_revinclude leakage covered in scenario catalog

Phase 4 — Documentation and demo

  • examples/smart-authz — demonstrates unrestricted vs patient-scoped vs policy-narrowed principals over real HTTP handler
  • Updated pkg/auth and pkg/testkit READMEs

Acceptance criteria

Criterion Status
≥30 documented authorization scenarios in CI ✅ 46 scenarios
Every data path has ≥1 deny scenario ✅ REST, search, view, AI, sync, modules
Patient-scoped search cannot return out-of-compartment resources ✅ tested
Policy deny overrides SMART scope allow ✅ tested
Token expiry and replay scenarios tested ✅ exp/nbf/iss/aud via authztest + smart tests
CheckPatientScope no longer marked stub
examples/smart-authz demo

Out of scope (per issue)

  • Full OAuth2/OIDC server, Inferno CI (Phase 5 stretch), SMART 2.2 granular scopes (documented deferral)

Test plan

  • go test ./pkg/testkit/authztest/...
  • go test ./pkg/auth/... ./pkg/smart/... ./pkg/http/...
  • go run ./examples/smart-authz/
Open in Web Open in Cursor 

cursoragent and others added 4 commits September 8, 2026 04:35
Implement issue #8 Phase 1-4: pkg/testkit/authztest with 46 documented
authorization scenarios covering REST CRUD, patient compartment, search
filtering, view/AI/sync/module paths, SMART token semantics, and
scope-vs-policy conflicts.

Harden patient scope: rename engine constraint helper, update docs to
remove stub language, enforce patient scope on bundle entry resources.

Add smart.ScopePolicyAuthChecker, DefaultConfiguration metadata helper,
and examples/smart-authz demonstrating restricted vs unrestricted principals.

Co-authored-by: Adegoke Adewoye <[email protected]>
- Run gofmt on four files flagged by CI / ci check
- Merge origin/main to bring in conformance/package-lock.json and
  .github/workflows/conformance.yml (fixes Conformance job setup-node cache)

Co-authored-by: Adegoke Adewoye <[email protected]>
…le HEAD

The lock pinned 3c4aa77 from a pre-squash branch commit that is not in
main history. CI shallow checkout cannot resolve it, so git cat-file -e fails.
Set gitCommit to current HEAD (valid as HEAD^ after this commit).

Co-authored-by: Adegoke Adewoye <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API security: SMART 2.2 readiness and authorization semantics test suite

2 participants