Repository navigation
providers/oauth2: don't set state in responses if not supplied - #9735
Conversation
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Thanks for the PR! I'll have to do some reading but iirc as part of OIDC the state parameter is required? In that case we'd have to enforce it being set when the openid scope is set |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9735 +/- ##
==========================================
- Coverage 93.01% 92.98% -0.03%
==========================================
Files 1230 1230
Lines 85771 85826 +55
Branches 4894 4894
==========================================
+ Hits 79778 79806 +28
- Misses 5906 5933 +27
Partials 87 87
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
I may be reading the wrong place, but https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest reads:
|
|
Hi! Any chance this would be a straightforward review for you @BeryJu or someone else given the spec clarification above? Thanks! |
* pass `next` value to IdP as `state`, with additional random prefix * this makes the "next" value more trusted * fix support for Authentik and other IdPs which do not support auth URLs without `state` (goauthentik/authentik#9735) * may also improve support for IdPs which lack PKCE support (see: https://github.com/panva/openid-client/blob/1486c3a020af8d12449d1d6a4bdf4f2bf4d32b77/README.md#authorization-code-flow) Closes #1134 Closes #1135
| query_params = parse_qs(uri.query) | ||
| query_params["code"] = code.code | ||
| query_params["state"] = [str(self.params.state) if self.params.state else ""] | ||
| if self.params.state != None: |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…t supplied Extend the fix to the form_post and implicit/hybrid responses, use the same truthiness rule as AuthorizeError, and add tests for the code (query, fragment, form_post) and implicit flows without state. Co-Authored-By: Alex Anderson <[email protected]>
RFC 6749 §4.1.2/§4.2.2/§4.1.2.1 require returning the exact state value whenever the parameter was present in the request, including when it is empty. Check for presence (is not None) instead of truthiness in both success and error responses, and keep blank values when re-parsing the response URL for form_post and the ui_locales redirect rewrite. Co-Authored-By: Alex Anderson <[email protected]>
BeryJu
left a comment
There was a problem hiding this comment.
I generally gravitated more towards not doing this and rather having a strict state requirement, but since the spec doesn't require state (and neither does OAuth 2.1 for that matter) I suppose it makes sense to merge this for compatibility
…b-controller' into web/admin/breadcrumb-controller * refs/remotes/origin/web/admin/breadcrumb-controller: (214 commits) The updated format for crumbs required an update to the unit tests. web/admin: Add a Breadcrumb context manager to the navigation suite Adding the Breadcrumbs visual component. Revised naming code to track certain features. web/elements: vendor sidebar and add icons (#27289) providers/oauth2: don't set state in responses if not supplied (#9735) web/elements: expansion visual hierarchy (#27562) providers/oauth2: accept ML-DSA keys for DPoP (#27174) website/docs: draft 2026.11 release notes (#26814) sources/ldap: store the directory date when resetting a password (#27578) events: bundle DB-IP Lite GeoIP databases instead of MaxMind GeoLite2 (#27102) web/admin: fix ldap source parent group form (#26421) stages/prompt: preserve empty initial values (#25148) core: batch expired cache and channel record cleanup (#27587) web: bump mermaid from 11.16.0 to 12.3.0 in /website (#27598) ci: bump taiki-e/install-action from 2.89.0 to 2.89.1 in /.github/actions/setup (#27630) core: bump goauthentik/fips-python from `d4c46c4` to `69e7058` in /lifecycle/container (#27626) ci: bump AndreKurait/docker-cache from 0.7.0 to 0.7.1 in /.github/actions/setup (#27628) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 in /.github/actions/setup (#27629) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 (#27627) ...
…k-controller * web/admin/breadcrumb-controller: (215 commits) Changes requested by reviewer (@GirlBossRush). The updated format for crumbs required an update to the unit tests. web/admin: Add a Breadcrumb context manager to the navigation suite Adding the Breadcrumbs visual component. Revised naming code to track certain features. web/elements: vendor sidebar and add icons (#27289) providers/oauth2: don't set state in responses if not supplied (#9735) web/elements: expansion visual hierarchy (#27562) providers/oauth2: accept ML-DSA keys for DPoP (#27174) website/docs: draft 2026.11 release notes (#26814) sources/ldap: store the directory date when resetting a password (#27578) events: bundle DB-IP Lite GeoIP databases instead of MaxMind GeoLite2 (#27102) web/admin: fix ldap source parent group form (#26421) stages/prompt: preserve empty initial values (#25148) core: batch expired cache and channel record cleanup (#27587) web: bump mermaid from 11.16.0 to 12.3.0 in /website (#27598) ci: bump taiki-e/install-action from 2.89.0 to 2.89.1 in /.github/actions/setup (#27630) core: bump goauthentik/fips-python from `d4c46c4` to `69e7058` in /lifecycle/container (#27626) ci: bump AndreKurait/docker-cache from 0.7.0 to 0.7.1 in /.github/actions/setup (#27628) ci: bump actions-rust-lang/setup-rust-toolchain from 2.0.0 to 2.0.1 in /.github/actions/setup (#27629) ...
|
OAuth 2.1 also has mandatory PKCE, which doesn't get you 100% of the benefit of |
I think this fixes a bug in OAuth2 / OpenID Connect (OIDC) implementation, as reported at getodk/central-backend#1135 (comment)
I guess this PR would ideally include tests which would fail without the code changes.