-
Notifications
You must be signed in to change notification settings - Fork 4
ADR-004: Authentication API #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c9d78b1
ADR-004: Authentication API
reinkrul f8014ea
fix
reinkrul db326c9
Update docs/adr/004-authentication-api.md
reinkrul 4e1cb36
Update docs/adr/004-authentication-api.md
reinkrul 9c3b48c
feedback
reinkrul 96282d7
no auth API as option
reinkrul b3511f9
feedback
reinkrul 40528c6
Update docs/adr/004-authentication-api.md
reinkrul 3e90ea5
Update docs/adr/004-authentication-api.md
reinkrul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| # Authentication API | ||
|
|
||
| ## Context and Problem Statement | ||
|
|
||
| We need to decide if, and how, EHRs will interact with the Knooppunt for authentication towards remote EHR systems. | ||
|
|
||
| It could be used for the following use cases: | ||
|
|
||
| 1. Machine-to-machine authentication of a care organization, for usage in data exchanges with other care organizations. | ||
| 2. End-user authentication of a caregiver using DEZI, for: | ||
| - Logging into the local EHR, and | ||
| - Data exchanges with other care organizations. | ||
|
|
||
| ### Design Goals | ||
|
|
||
| We want a solution that is easy to integrate in varying (existing) environments, without compromising on security and | ||
| simplicity. | ||
|
|
||
| Key design goals are: | ||
|
|
||
| - **Pluggability**: Should be as easy as possible to integrate, e.g. with existing client library support. | ||
| - Existing Nuts implementations could be leveraged, if possible. | ||
|
|
||
| ## Considered Options | ||
|
|
||
| This section describes the considered options. | ||
|
|
||
| ### Nuts v2 auth API | ||
|
|
||
| If the GF Authentication specifies Nuts as authentication mechanism, the EHR can use the Nuts v2 authentication API to | ||
| obtain access tokens for remote EHR systems. | ||
|
|
||
| It's a tailor-made REST API of the Nuts node, but can be used to | ||
|
|
||
| Advantages: | ||
|
|
||
| - Vendors with existing Nuts node implementations can use their existing implementation. | ||
|
|
||
| Disadvantages: | ||
|
|
||
| - Tailor-made API, so requires custom client implementation. | ||
| - Only works for Nuts-based authentication. | ||
|
reinkrul marked this conversation as resolved.
Outdated
|
||
| - The EHR will still need to integrate DEZI (an OpenID Connect API) for caregiver authentication. | ||
|
reinkrul marked this conversation as resolved.
Outdated
|
||
| - The DEZI id_token will have to be wrapped in a Verifiable Credential for usage in Nuts, adding complexity. | ||
|
|
||
| ### OAuth2 / OpenID Connect | ||
|
reinkrul marked this conversation as resolved.
Outdated
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OAuth for machine-2-machine authentication makes semantically no sense. You are pretending to be an OAuth token endpoint, but it is only an endpoint to initiate the request to another token endpoint. This can lead to confusion and misuse. |
||
|
|
||
| The Knooppunt could expose an OAuth2 / OpenID Connect (OIDC) API for end-user, and machine-to-machine authentication, | ||
| using standardized protocols | ||
|
|
||
| Advantages: | ||
|
|
||
| - Standard protocol, with existing client libraries for many programming languages. | ||
| - Supports multiple grant types, allowing for both machine-to-machine and end-user authentication. | ||
|
|
||
| Disadvantages: | ||
|
reinkrul marked this conversation as resolved.
|
||
|
|
||
| - More complexity in the Knooppunt and deployment; it requires the Knooppunt to implement an OAuth2 / OIDC Provider, | ||
| and the vendor to configure OAuth2/OIDC clients in their EHR systems and Knooppunt. | ||
|
|
||
| #### End-user authentication | ||
|
|
||
| For end-user authentication, the **OIDC Authorized Code** flow can be used to authenticate caregivers using DEZI. | ||
|
reinkrul marked this conversation as resolved.
Outdated
|
||
|
|
||
| Although DEZI looks like a standard OpenID Connect Provider implementation, it could do heavy lifting like decrypting | ||
| the `id_token`. | ||
|
|
||
| Note: supporting this OIDC flow is optional; the EHR could choose to directly integrate with DEZI, using the decrypted | ||
| `id_token` for machine-to-machine authentication. | ||
|
|
||
| #### Machine-to-machine authentication | ||
|
|
||
| In machine-to-machine authentication, the care organization is always authenticated. | ||
| In cases the data exchange requires a user identity, the pre-authenticated end-user is also included in the form of a | ||
| decrypted DEZI `id_token`. | ||
|
|
||
| There are several OAuth2 grant types that can be used for machine-to-machine authentication: | ||
|
|
||
| ##### OAuth2 Client Credentials | ||
|
|
||
| The EHR authenticates to the Knooppunt using its `client_id` and static `client_secret` to obtain an access token, | ||
| providing a custom parameter for the end-user DEZI `id_token` if needed. | ||
|
|
||
| Advantages: | ||
|
|
||
| - Simplicity: widely understood and easy to implement. Most OAuth2 libraries and frameworks natively support this flow. | ||
| - Mature and standardized: broad industry adoption and extensive tooling/support. | ||
| - Good for pure system-level communication: ideal when only the organization (not an end-user) needs to be | ||
| authenticated. | ||
| - Low integration overhead: minimal requirements for token construction or signing logic. | ||
|
|
||
| Disadvantages: | ||
|
reinkrul marked this conversation as resolved.
|
||
|
|
||
| - Static credentials: requires secure management of client secrets, | ||
| which can be hard in distributed or multi-tenant systems. | ||
| - No built-in user context: can't represent a caregiver or end-user identity unless additional tokens | ||
| (e.g., DEZI `id_token`s) are manually encoded and included. | ||
| - Limited delegation model: No standard way to represent "on behalf of" relationships or token chaining between systems. | ||
|
|
||
| ##### OAuth2 JWT Bearer Grant (RFC7523) | ||
|
|
||
| Using this grant type EHR authenticates to the Knooppunt using a signed JWT assertion, which can include both the care | ||
| organization | ||
| and end-user identity (from the DEZI `id_token`). | ||
|
|
||
| Semantically identical to Client Credentials, but uses a signed JWT for authentication instead of static client secrets, | ||
| which makes it a bit easier to include end-user identity (a JSON object) in the JWT claims. | ||
|
|
||
| Advantages: | ||
|
|
||
| - More flexible: allows inclusion of additional claims (like end-user identity) in the JWT assertion without manual | ||
| encoding on JSON objects to strings. | ||
|
reinkrul marked this conversation as resolved.
Outdated
|
||
| - Improved security: leverages asymmetric cryptography for authentication, reducing risks associated with static | ||
| secrets. | ||
|
|
||
| Disadvantages: | ||
|
|
||
| - Increased complexity: requires JWT creation and signing logic, which may not be natively supported in all OAuth2 | ||
| libraries. | ||
| - Still limited delegation model: while more flexible than Client Credentials, it still lacks standardized support for | ||
| complex "on behalf of" scenarios. | ||
|
|
||
| ##### OAuth 2.0 Token Exchange (RFC8693) | ||
|
|
||
| [OAuth 2.0 Token Exchange](https://www.rfc-editor.org/rfc/rfc8693.html) is a newer OAuth2 grant type that allows one | ||
| token to be exchanged for another, | ||
| supporting "on behalf of" scenarios. | ||
| Using this flow, the EHR can exchange the DEZI `id_token` at the Knooppunt for an access token to a remote EHR system, | ||
| representing both the care organization and the authenticated caregiver. | ||
|
|
||
| Advantages: | ||
|
|
||
| - Very good fit for "on behalf of" scenarios: designed specifically to handle cases where an application needs to act on | ||
| behalf of a user. | ||
|
|
||
| Disadvantages: | ||
|
|
||
| - The RFC is still a "proposed standard", so not officially an established standard yet. | ||
| - Limited library support. | ||
|
|
||
| ## Decision Outcome | ||
|
|
||
| Proposal: | ||
|
|
||
| - Optional OIDC Provider in the Knooppunt for end-user authentication using DEZI. | ||
| - OAuth2 API in the Knooppunt for machine-to-machine authentication, supporting at least: | ||
|
reinkrul marked this conversation as resolved.
Outdated
|
||
| - OAuth2 Client Credentials grant. | ||
| - OAuth2 Token Exchange if supported by enough vendors. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.