Repository navigation
fix(auth): strip trailing slash from OIDC issuer before discovery - #18530
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughOIDC metadata loading now removes trailing slashes from the issuer before constructing the discovery URL. A unit test verifies that the request contains one slash before ChangesOIDC discovery
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This is a localized fix for OIDC discovery URLs with trailing-slash issuers, supported by unit-test changes; no actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Lynn-Inf
left a comment
There was a problem hiding this comment.
LGTM — a solid change that improves code compatibility.
wangq8
left a comment
There was a problem hiding this comment.
LGTM, simple and correct. ✅
The fix (issuer.rstrip('/')) removes trailing slashes before joining /.well-known/openid-configuration, which prevents the double-slash URL that 404s on providers like authentik. The issuer used later for ID-token validation still comes from the discovery document itself, so no other part of the flow is affected — the PR description is accurate on that point.
The test correctly monkeypatches sync_request and asserts the exact requested URL. rstrip('/') stripping all trailing slashes is the desired behavior here.
One tiny, non-blocking observation: rstrip('/') will also strip a trailing slash if the issuer is ever just "/" (yielding an empty string), but that's already guarded upstream by the "Missing issuer in configuration" check, so it's a non-issue in practice.
Summary
OIDC discovery builds its URL as
f"{issuer}/.well-known/openid-configuration". Providers whose issuer carries a trailing slash therefore get asked for a URL with a double slash in it, which 404s. authentik is one of them: its issuer ishttps://auth.example.com/application/o/<app>/, so the request goes to.../o/<app>//.well-known/openid-configurationand login fails right at the start withFailed to fetch OIDC metadata.Stripping trailing slashes off the issuer before joining the well-known path is enough. The
issuerused later for ID token validation still comes from the discovery document itself, so nothing else about the flow changes.