Repository navigation
providers/oauth2: OpenID key binding support - #22590
Conversation
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #22590 +/- ##
==========================================
+ Coverage 92.61% 92.79% +0.17%
==========================================
Files 1051 1056 +5
Lines 61983 62716 +733
Branches 424 424
==========================================
+ Hits 57408 58196 +788
+ Misses 4575 4520 -55
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
…nt, fixes RSA key size computation
Signed-off-by: Ethan Heilman <[email protected]>
Signed-off-by: Jens Langhammer <[email protected]>
Signed-off-by: Jens Langhammer <[email protected]>
Signed-off-by: Jens Langhammer <[email protected]>
Signed-off-by: Jens Langhammer <[email protected]> # Conflicts: # authentik/providers/oauth2/views/token.py
Signed-off-by: Jens Langhammer <[email protected]>
Signed-off-by: Jens Langhammer <[email protected]>
gergosimonyi
left a comment
There was a problem hiding this comment.
Seems clean, thank you for the contribution!
I'll leave it to @BeryJu to merge
…int/ak-progress * web/typo/enterprise-status-card-properties: (41 commits) The language between licensed and isLicensed was confusing, so internally the progressBar expression uses 'allowed' for the number of licensed users, and 'licensed' for the overall state of the product. The severities ought to be in order, otherwise it's a mental pause. Another typo. Noticed a typo; prettier had an opinion. web/maint: clean-up ak-enterprise-status-card Some revisions to the enterprise status card. policies: make policy bindings expire-able (#24116) enterprise/endpoints/connectors/fleet: pass populate_policies (#24108) lifecycle/container: drop curl and runit (#24008) lib: move ExpiringModel to lib from core (#24109) web, docs, packages/*: Fix pnpm Workspace Catalogs (#23944) providers/oauth2: OpenID key binding support (#22590) core: bump github.com/go-ldap/ldap/v3 from 3.4.13 to 3.4.14 (#24088) core: bump uvicorn[standard] from 0.50.2 to 0.51.0 (#24089) core: bump coverage[toml] from 7.15.0 to 7.15.1 (#24090) core: bump uuid from 1.23.4 to 1.23.5 (#24091) core: bump json-subscriber from 0.2.8 to 0.3.0 (#24092) ci: bump softprops/action-gh-release from 3.0.1 to 3.0.2 (#24093) ci: bump actions/setup-node from 6.4.0 to 7.0.0 (#24094) ci: bump actions/setup-node from 6.4.0 to 7.0.0 in /.github/actions/setup (#24096) ...
# Which Problems Are Solved This PR adds client support for [OpenID Key Binding 1.0](https://openid.net/specs/openid-connect-key-binding-1_0.html) a draft standard for Proof-of-Possession ID Tokens. Basically ID Tokens that have a public key enabling the user to sign under their identity. OpenPubkey supports key binding using zitadel/oidc as the library. However because zitadel/oidc does not natively support key binding, OpenPubkey has to use [a fragile rounder-tripper work around for the RP](https://github.com/openpubkey/openpubkey/blob/main/providers/keybinding_provider.go#L109). This PR allows key binding support for OP and RP: - Authorization code flow - Device code flow - Refresh flow - Unit tests This PR is only for client/RP. It does not add key binding to the OP code. I would like to add that at a future point, but client/RP support the main blocker to using plain zitadel/oidc with key binding. I've run manual tests for code flow, refresh and device flow using the key binding with the Hello OP and this PR in OpenPubkey that runs against this branch: openpubkey/openpubkey#395 # How the Problems Are Solved Adds a `WithKeyBinding` option to RP so that the RP can request key bound ID Tokens from the OP and a `KeyBindingRelyingParty` to perform the additional steps used by key binding. ```golang func WithKeyBinding(signer crypto.Signer, alg jose.SignatureAlgorithm) Option ``` # Additional Changes No additional changes # Additional Context Do you want me to port this to v4 as well as v3? Relevant PRs - PR adding Key Binding to Authentik goauthentik/authentik#22590 - [OpenID Key Binding 1.0 Latest Draft](https://openid.net/specs/openid-connect-key-binding-1_0.html) - PR to use this RP option in OpenPubkey openpubkey/openpubkey#395 --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]> Co-authored-by: Wim Van Laer <[email protected]>
Details
This PR adds OpenID Key Binding to authentik. OpenID Key Binding binds a public key to an ID Token using mechanisms defined in RFC9449, OAuth 2.0 Demonstrating Proof of Possession (DPoP). For more details see the draft OpenID spec for Key Binding https://openid.github.io/connect-key-binding/main.html
We add key binding support for the authorization code, device code and refresh flows fully supporting all flows specified in the draft standard. The draft standard does not key bind the access token and we follow that here.
The PR contains:
key_boundscope to list of scopesdpop+id_tokendpop_jktto authorizationcode, devicetoken and refreshtoken models. This is needed to remember the public key bound to token for each of those flows.jticlaims in the authentik cache to protect against replay attacksCurrently this doesn't make any changes to docs since it doesn't seem there is a doc per flow type in the docs directory, but if docs for this feature is desired, I do have some I could can add.
Checklist
ak test authentik/)make lint-fix)If an API change has been made
make gen)If changes to the frontend have been made
make web)If applicable
make docs)Appendix
These are largely for my own notes to document my design decisions. Feel free to read, but not required to understand to review the PR.
Replay protection and JTI
Following the recommendation given in RFC 9449 Token Replay, we use the
jticlaim in the DPOP proof to detect replayed DPoP proofs:To do this we employ authentiks caching mechanism to store these proofs for 3 minutes. Any proof older or newer than 60 seconds is considered expired and rejected. We enforce a max JTI string size of 256 characters
An assumption we make here is that the cache is shared between all instances of authentik or all instances of authentik at an URI. If this was not the case, would be possible a DPoP proof can be replayed. Preventing replay is not a requirement of DPoP with the standard stating:
JTI or (JTI AND HTU)
We check only uniqueness of the
jtiin the cache. It would be allowed by the standard to store thejtiand thehtu(URI of the request) in the cache and then only reject if the pair (jti,htu) was not unique. We choose to check uniqueness ofjtiand not the pair (jti,htu) to "fail faster" and make finding bugs easier. If someone is using a non-uniquejtiwe want them to get errors early so they can fix it in testing. Using thehtumight hide a non-randomjtibug.Is JTI strictly needed here?
We support three flows: authorization code, device code and refresh flow. The authorization code and the device code flows use the hash of the auth_code or the device code as the claim
c_s256in the DPoP proof functioning like a nonce. This should prevent DPoP replays and makes thejticheck in these flows unnecessary. Only the refresh flow has a security benefit from thejticheck. So why not skip thejticheck for the authorization code and device code?jticheck is recommended by standard and expected. If a developer noticed that thejticheck is not happening, they might assume this is a security bug and report it. Better to do the expected thing to reduce false positives.jtiallows the dpop code added in this PR to be used for dpop as authentik adopts dpop more generally.