-
Notifications
You must be signed in to change notification settings - Fork 810
Fix double oauth2_provider mountpoint in oidc view #957
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
Fix double oauth2_provider mountpoint in oidc view #957
Conversation
Fixes the doubling of mountpoint path in the OIDC endpoints values for `.well-known/openid-configuration/`
According to the `django-oauth-toolkit` documentation for [OIDC_ISS_ENDPOINT](https://django-oauth-toolkit.readthedocs.io/en/latest/settings.html#oidc-iss-endpoint) this settings variable should enable discovery at `OIDC_ISS_ENDPOINT` + `/.well-known/openid-configuration/`. But if you use the variable as described you'll end up with the correct URL for the `issuer` value but incorrect URL's for the values of `authorization_endpoint`, `token_endpoint`, `userinfo_endpoint`, and `jwks_uri`. So if the `OIDC_ISS_ENDPOINT` is `http://localhost:8001/some-initial-path/o` the `issuer` will be `http://localhost:8001/some-initial-path/o` but `authorization_endpoint` will be `http://localhost:8001/some-initial-path/o/some-initial-path/o/authorize/`. Same pattern for `token_endpoint`, `userinfo_endpoint`, and `jwks_uri` This commit updates the tests to expect `OIDC_ISS_ENDPOINT` to end in `/o`
Codecov Report
@@ Coverage Diff @@
## master #957 +/- ##
=======================================
Coverage 96.60% 96.61%
=======================================
Files 31 31
Lines 1710 1713 +3
=======================================
+ Hits 1652 1655 +3
Misses 58 58
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add the changelog entry?
It's been added👌 |
@dollarklavs is it safe to say that, given this is affecting the connection discovery view, that in the current release this is just outright broken (since the URLs are wrong), and so people upgrading don't need to take special precautions when upgrading if they are using this setting (since supposedly the feature just isn't working)? If there's some big-ish changes we might want to add something to the changelog to make it clear that this change affects people using this specific setting. Things otherwise look good to me as well |
@rtpg I would think that OIDC in the current release is broken. So yeah no need to take special precautions - but I/we could probably have overlooked a use case that incorporates the previous implementation. |
I think that would be good, yeah. So if somoene is looking over the release notes and are using OIDC they'll click through and maybe realize the change does (or more likely doesn't!) affect them. Thanks for the detailed reply. |
To include possible breaking change message
@rtpg Changelog updated🥳 |
I reviewed and aprpoved, and previously there was only a changelog request.
@dollarklavs @rtpg I'm concerned that you think OIDC in the current release is broken as I've been using it as have others. I hope this PR hasn't caused a breaking change. @MattBlack85 and I will need to re-review before we publish a release. |
Going to try and summarize the issue, because I think the issue itself is relatively limited in scope:
then what I get back from the above
(note the doubling of But if you don't use this setting, everything seems fine! Hence this not being a major issue yet, I think. Hope this helps |
Fixes the doubling of mountpoint path in the OIDC endpoints values for
.well-known/openid-configuration/
According to the
django-oauth-toolkit
documentation for OIDC_ISS_ENDPOINT this settings variable should enable discovery atOIDC_ISS_ENDPOINT
+/.well-known/openid-configuration/
. This behaviour is backed by the OIDC specs.But if you use the variable as described you'll end up with the correct URL for the
issuer
value but incorrect URL's for the values ofauthorization_endpoint
,token_endpoint
,userinfo_endpoint
, andjwks_uri
in the json response when calling/.well-known/openid-configuration/
.So if the
OIDC_ISS_ENDPOINT
ishttp://localhost:8001/some-initial-path/o
theissuer
will behttp://localhost:8001/some-initial-path/o
butauthorization_endpoint
will behttp://localhost:8001/some-initial-path/o/some-initial-path/o/authorize/
. Same pattern fortoken_endpoint
,userinfo_endpoint
, andjwks_uri
Fixes #955
Description of the Change
Instead of concatting
OIDC_ISS_ENDPOINT
with the output ofreverse
for the different OIDC views, first useurlparse
to stripOIDC_ISS_ENDPOINT
to only scheme + netloc (eg.http
+://
+localhost:8000
).Also updates tests to expect an
OIDC_ISS_ENDPOINT
that ends in/o
.Checklist
CHANGELOG.md
updated (only for user relevant changes)AUTHORS