Summary
HAIStack provides SMART scope parsing, JWT validation, backend-service client assertions, and a deny-by-default policy engine — but authorization semantics are under-tested and partially stubbed. A successful OAuth/SMART token exchange is not an authorization test. We need explicit, CI-enforced scenarios covering restricted principals, patient-compartment boundaries, denied resources, search-result filtering, token expiry, backend-service clients, and policy narrowing of apparently valid scopes.
Problem / gap
What we have today
pkg/smart (v1 — done per roadmap):
- Scope parsing and matching (
patient|user|system read/write)
- JWT claim validation (iss/aud/exp/nbf)
- Backend-service client assertions with mandatory
jti replay protection
AuthAdapter translating SMART inputs into pkg/auth principals
pkg/auth (v1 — done per roadmap):
- Principals, roles, permissions, tenant/device context
- Deny-by-default JSON/YAML policy DSL
- Resource, view, AI tool, sync, and module install checks
CheckPatientScope — explicitly documented as a stub in places
AuditingEngine for optional allow/deny event emission
pkg/http:
- Pluggable
PrincipalResolver + AuthChecker
- Auth disabled by default when hooks are nil
- No built-in OAuth2/SMART token endpoint or
.well-known/smart-configuration server routes
pkg/client:
- SMART discovery, auth-code + PKCE, backend client assertion token exchange
- No SMART 2.2-specific scope features or test vectors
Testing:
- Unit tests in
pkg/auth/auth_test.go cover some patient-scope cases
- No integrated authorization scenario matrix across HTTP → search → view → AI paths
- No Inferno SMART App Launch tests in CI
- No tests for "scope grants access but policy denies" (SMART's explicit warning)
What is missing
-
Semantic authorization test suite — not OAuth flow tests, but access-control outcome tests:
- User with restricted role cannot read/write denied resource types
- Patient-scoped principal can only access their compartment
- Patient-scoped search returns filtered results (not full index)
- Direct read of out-of-scope resource returns 403/404 as appropriate
- Token past
exp rejected; nbf in future rejected
- Backend-service client (
system/*.read) vs user context behave differently
- Policy rule narrows scope (e.g.
patient/*.read granted but policy allows only Observation)
- Consent/policy change mid-session affects subsequent requests
- View execution (
pkg/view) and AI tool calls (pkg/ai) respect same policy as REST
-
Patient compartment completeness
CheckPatientScope stub must become production-grade for edge deployments
- Search layer must apply patient-scope filters consistently (not just read path)
_include / _revinclude must not leak out-of-scope resources
-
SMART 2.2 readiness
- Evaluate SMART 2.2 granular scopes, context parameters, and ecosystem support
- Document target SMART version and compatibility matrix
- Add test vectors for 2.2 scope formats where adopted
-
Server-side SMART surface (host contract)
- HAIStack may not own OAuth servers, but should document and optionally provide:
.well-known/smart-configuration response shape for pkg/http hosts
- Example
PrincipalResolver + AuthChecker wiring for SMART Bearer tokens
- Reference integration test harness (mock auth server + real policy enforcement)
-
Negative test catalogue
- Documented matrix of "principal X, action Y, resource Z → expect deny"
- Golden OperationOutcome responses for authorization failures
Why this matters for HAIStack
- Core value proposition: "Safe AI access" (
pkg/ai) and permissioned views (pkg/view) depend entirely on auth — a token parsing success that over-authorizes defeats the product story.
- Edge/offline deployments: May not use a full IdP; device trust + local policy must still enforce compartment boundaries.
- SMART ecosystem reality: SMART warns that underlying policy may narrow apparently valid scopes — HAIStack's policy DSL is exactly that layer, but it is untested as a system.
- Integration partners: Will ask for evidence beyond "we parse scopes" — they need scenario-based proof.
Proposed scope
Phase 1 — Authorization scenario test kit
Phase 2 — Token and SMART semantics
Phase 3 — Patient scope hardening
Phase 4 — Documentation and host contract
Phase 5 — External conformance (stretch)
Acceptance criteria
Out of scope (for this issue)
- Building a full OAuth2/OIDC authorization server
- EHR/standalone SMART launch UI orchestration
- Dynamic client registration server
- Refresh token lifecycle management
Affected packages / files
| Area |
Path |
| Policy engine |
pkg/auth/ |
| SMART adapters |
pkg/smart/ |
| HTTP middleware |
pkg/http/ |
| Search |
pkg/search/ |
| Views |
pkg/view/auth.go |
| AI tools |
pkg/ai/ |
| Sync |
pkg/sync/, pkg/modules/auth.go |
| Test kit |
pkg/testkit/ |
| Examples |
examples/ai-authz, new examples/smart-authz |
References
- SMART App Launch 2.2
- SMART guidance: underlying policy may narrow apparently valid scopes
- HAIStack
pkg/smart/README.md — v1 scope and explicit out-of-scope items
- HAIStack
pkg/auth/README.md — patient-scope stub note
Related issues
- Conformance artefacts (IG + examples)
- Bulk Data (backend-service client authorization for export)
- Benchmark harness (concurrent authz under load)
Summary
HAIStack provides SMART scope parsing, JWT validation, backend-service client assertions, and a deny-by-default policy engine — but authorization semantics are under-tested and partially stubbed. A successful OAuth/SMART token exchange is not an authorization test. We need explicit, CI-enforced scenarios covering restricted principals, patient-compartment boundaries, denied resources, search-result filtering, token expiry, backend-service clients, and policy narrowing of apparently valid scopes.
Problem / gap
What we have today
pkg/smart(v1 — done per roadmap):patient|user|systemread/write)jtireplay protectionAuthAdaptertranslating SMART inputs intopkg/authprincipalspkg/auth(v1 — done per roadmap):CheckPatientScope— explicitly documented as a stub in placesAuditingEnginefor optional allow/deny event emissionpkg/http:PrincipalResolver+AuthChecker.well-known/smart-configurationserver routespkg/client:Testing:
pkg/auth/auth_test.gocover some patient-scope casesWhat is missing
Semantic authorization test suite — not OAuth flow tests, but access-control outcome tests:
exprejected;nbfin future rejectedsystem/*.read) vs user context behave differentlypatient/*.readgranted but policy allows onlyObservation)pkg/view) and AI tool calls (pkg/ai) respect same policy as RESTPatient compartment completeness
CheckPatientScopestub must become production-grade for edge deployments_include/_revincludemust not leak out-of-scope resourcesSMART 2.2 readiness
Server-side SMART surface (host contract)
.well-known/smart-configurationresponse shape forpkg/httphostsPrincipalResolver+AuthCheckerwiring for SMART Bearer tokensNegative test catalogue
Why this matters for HAIStack
pkg/ai) and permissioned views (pkg/view) depend entirely on auth — a token parsing success that over-authorizes defeats the product story.Proposed scope
Phase 1 — Authorization scenario test kit
pkg/testkit/authztest/(or extendpkg/testkit) with:_include/_revincludeleakage preventionpkg/view)pkg/ai)pkg/syncdevice trust)pkg/modules)Phase 2 — Token and SMART semantics
pkg/smarttests:expin past)nbfin future)aud/issjtireplay (already partially covered — ensure HTTP-integrated)examples/smart-authzrunnable demo wiring mock tokens → policy → HTTPPhase 3 — Patient scope hardening
CheckPatientScopestub with production implementation:_historypkg/httpwithAuthMiddlewareenabledPhase 4 — Documentation and host contract
smart.AuthAdapter→auth.PolicyEngine→ data pathsPrincipalResolverimplementation for Bearer JWT + SMART scopes.well-known/smart-configurationPhase 5 — External conformance (stretch)
pkg/httpdeploymentAcceptance criteria
pkg/authpatient scope no longer marked as stub in docsexamples/smart-authzdemonstrates restricted vs unrestricted principalsOut of scope (for this issue)
Affected packages / files
pkg/auth/pkg/smart/pkg/http/pkg/search/pkg/view/auth.gopkg/ai/pkg/sync/,pkg/modules/auth.gopkg/testkit/examples/ai-authz, newexamples/smart-authzReferences
pkg/smart/README.md— v1 scope and explicit out-of-scope itemspkg/auth/README.md— patient-scope stub noteRelated issues