Skip to main content

Authentication

How a caller proves who they are, how a request is bound to a project, and how access is decided once identity is established.

In one paragraph​

MedBackend does not run its own user directory. It validates JWTs issued by an OAuth / OpenID Connect provider and maps two claims out of the token onto a FHIR resource: an entity type (Patient, Practitioner, RelatedPerson, Device) and an entity id (that resource's FHIR logical id). Which claim names carry those values is configuration. Everything downstream — validation rules, compartment checks, the Me query — operates on that resolved pair.

Credentials​

MethodWho uses itDocumented in
OAuth / OIDC bearer tokenPatients, practitioners, related personsIdentity Providers
Device API key exchanged for a tokenDevices, workers, integrations, AI modelsDevice Authentication
Developer API keyYour own scripts, CI and agents configuring the project — never reading its dataDeveloper API Keys

Every request names a project​

A valid token is not sufficient on its own. Each request also carries an X-Project-ID header, and the token must name the same project. If the two disagree, or the header is absent, the request is refused. This is the boundary between projects and it fails closed — see the project binding.

Where to start​

  1. Making Authenticated Requests — headers, a first request, confirming your identity with Me. Start here.
  2. Identity Providers — connecting an OAuth provider and mapping claims.
  3. Device Authentication — non-interactive callers.
  4. Developer API Keys — configuring a project from code.
  5. Requiring a Practitioner Role — restricting a rule to clinicians holding a specific role.
  6. How Access Is Decided — rules, validators, and the behaviour you cannot configure.

What an authenticated caller may actually do is covered separately under Validation.

Security notes​

  • Access defaults to denied. A role / resource / operation combination with no matching rule is refused. Missing configuration denies rather than permits.
  • X-Project-ID is required on every path that serves project data. /health and /metadata serve none and do not take it. A developer API key carries its project, so it does not need the header.
  • Device API keys are project-wide credentials. Treat them accordingly — see what a leaked device key exposes.
  • Token lifetimes are short by design, because there is no revocation list: one hour for user tokens, five minutes by default for device tokens.