4.8 KiB
Public API and security design
Routes
All routes return JSON as applicable. GUID route constraints apply. Login and guidance are anonymous; other routes require bearer authentication. Professional health-data reads additionally require a current configured assignment.
| Method | Route | Purpose / allowed role |
|---|---|---|
| POST | /api/authentication/login | Account/password login; anonymous |
| GET | /api/measurement-guidance | Versioned guidance; anonymous |
| GET | /api/professionals/me/patients | Configured assigned identifiers; professional |
| POST | /api/patients | Create own profile; patient |
| GET | /api/patients/me | Own profile; patient |
| GET | /api/patients/{patientId} | Own/assigned profile |
| PUT | /api/patients/{patientId} | Update own profile; patient |
| POST | /api/patients/{patientId}/observations | Record own observation; patient |
| GET | /api/patients/{patientId}/observations | Inclusive period/context-selected history |
| GET | /api/patients/{patientId}/observations/latest | Latest overall observation |
| GET | /api/observations/{observationId} | Actual owner's authorized observation |
| PUT | /api/observations/{observationId} | Update three measurement values; patient |
| PATCH | /api/observations/{observationId} | Presence-aware partial update; patient |
| DELETE | /api/observations/{observationId} | Delete own observation; patient |
| GET | /api/patients/{patientId}/insights | Numerical selected-period summary |
| GET | /api/patients/{patientId}/trends | Selected-period trend assessment |
| GET | /api/patients/{patientId}/overview | Profile, latest overall, selected insight |
| GET | /health/live | Authenticated process probe |
| GET | /health/ready | Authenticated key/catalog/schema-version probe |
History/insights/trends/overview require from/to and accept setting/activityCondition selection. Offset-free timestamps mean UTC; intervals are inclusive. Both selected dimensions must match. Unknown is an explicit category. Latest ignores the period/context selections. Overview explains the different latest and insight bases.
Identity and authorization
PrototypeAccounts uses configured password hashes with framework PasswordHasher. ASP.NET Core AddBearerToken issues opaque protected tickets containing account identity and role, with configured expiry (default 30 minutes, permitted 1–1440). There is no refresh mechanism. The persistent Data Protection key ring retains the application discriminator HealthApp.ApiGateway. Tickets contain no patient associations or professional assignment list.
AccessPolicy resolves the current account association through ProfileQueries, or checks predefined ProfessionalAssignments. Observation access first resolves its actual owner. Only the host can construct AuthorizedPatientContext; commands enforce its write capability. Professionals are read-only. The boundary checks access before body validation so unauthorized callers cannot learn resource details from model errors. No /by-account endpoint, backend ports, service-key authentication or internal HTTP callback exists.
Production rejects non-HTTPS requests. Protected responses and login use no-store; guidance is exempt. Config/leaf private key are protected by filesystem ownership; token keys are service-owned. Remote database connections require VerifyFull certificate and hostname verification. These are prototype security controls, not a claim of production certification.
Outcomes and failure boundary
| Condition | Observable behavior |
|---|---|
| Successful creation / deletion | 201 with relative Location / 204 |
| Missing, invalid or expired ticket | 401 |
| Forbidden role/write | 403 |
| Other patient's resource or unavailable owner | Empty 404; non-disclosure |
| Invalid model/period/selection | 400 |
| Duplicate account profile | 409 |
| Empty selected history | 200 [] with X-Measurement-Setting and X-Activity-Condition headers |
| Empty insight / empty trend | 404 / 200 with explicit unavailable values |
| Overview without observations | 200 with nullable latest/insight and explanation |
| Missing overview profile | 404 |
| Dependency unavailable or admission exhausted | 503; overload includes Retry-After: 1 |
| Request deadline / recognized dependency timeout | 504 if response can still be written |
| Caller abort | Connection aborted; transaction cleaned up |
Default bounded pool is 32, health admission 32, assessment admission 4, deadline 30 seconds. Login/guidance bypass health admission and DB transaction creation; professional-list and health probes also bypass this boundary. Readiness has its own DB metadata access. These values are configurable starting limits, not measured capacity guarantees. Failure logs include operation/status/correlation, not clinical payloads or identifying route values. Framework/EF logging is restricted by host filters.