Skip to content

fix(auth): strip trailing slash from OIDC issuer before discovery - #18530

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
krim404:fix/oidc-issuer-trailing-slash
Aug 20, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
krim404:fix/oidc-issuer-trailing-slash

Conversation

@krim404

@krim404 krim404 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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 is https://auth.example.com/application/o/<app>/, so the request goes to .../o/<app>//.well-known/openid-configuration and login fails right at the start with Failed to fetch OIDC metadata.

Stripping trailing slashes off the issuer before joining the well-known path is enough. The issuer used later for ID token validation still comes from the discovery document itself, so nothing else about the flow changes.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Aug 19, 2026
@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 09afff08-48c5-4249-8bf4-0ff4e13a1522

📥 Commits

Reviewing files that changed from the base of the PR and between c90a0b7 and 9273aac.

📒 Files selected for processing (2)
  • api/apps/auth/oidc.py
  • test/testcases/test_web_api/test_auth_app/test_oidc_client_unit.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

OIDC 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 .well-known/openid-configuration.

Changes

OIDC discovery

Layer / File(s) Summary
Normalize and test discovery URL
api/apps/auth/oidc.py, test/testcases/test_web_api/test_auth_app/test_oidc_client_unit.py
The metadata loader normalizes trailing issuer slashes before fetching OIDC metadata. The unit test verifies the normalized discovery URL.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 9273a

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

I’m a rabbit with a tidy URL,
No double slashes left to tell.
The issuer trail is trimmed with care,
Discovery hops through cleaner air.
Tests thump softly: all is well!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main OIDC issuer normalization change.
Description check ✅ Passed The description includes the required Summary section and clearly explains the failure, fix, affected provider, and validation impact.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN
JinHai-CN requested a review from wangq8 August 20, 2026 05:58
@wangq8 wangq8 added the ci Continue Integration label Aug 20, 2026
@wangq8
wangq8 requested a review from Lynn-Inf August 20, 2026 06:02

@Lynn-Inf Lynn-Inf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — a solid change that improves code compatibility.

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JinHai-CN
JinHai-CN merged commit 89d35d1 into infiniflow:main Aug 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants