-
Notifications
You must be signed in to change notification settings - Fork 9
fix(authenticator): redirect failed /auth/callback into the SPA with auth_error #2040
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
Changes from all commits
a8f7b69
3a11c93
fe4fa07
e6eb499
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -407,6 +407,19 @@ impl AuthenticatorConfig { | |||||||||||||||||||||||||||
| anyhow::ensure!(!value.trim().is_empty(), "{name} is required (empty)"); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // `default_return_to` lands verbatim in Location headers (login | ||||||||||||||||||||||||||||
| // fallback and every `auth_error` bounce). A non-site-relative value | ||||||||||||||||||||||||||||
| // would open-redirect on our own config, and a `#` fragment would hide | ||||||||||||||||||||||||||||
| // `auth_error=` from the SPA's query parsing — defeating its login | ||||||||||||||||||||||||||||
| // retry loop guard. | ||||||||||||||||||||||||||||
| anyhow::ensure!( | ||||||||||||||||||||||||||||
| self.default_return_to.starts_with('/') | ||||||||||||||||||||||||||||
| && !self.default_return_to.starts_with("//") | ||||||||||||||||||||||||||||
| && !self.default_return_to.contains('#') | ||||||||||||||||||||||||||||
| && !self.default_return_to.chars().any(char::is_control), | ||||||||||||||||||||||||||||
| "default_return_to must be a site-relative path without a fragment" | ||||||||||||||||||||||||||||
|
Comment on lines
+415
to
+420
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Reject backslash-based scheme-relative redirects. Line 416 accepts Proposed fix self.default_return_to.starts_with('/')
&& !self.default_return_to.starts_with("//")
+ && !self.default_return_to.contains('\\')
&& !self.default_return_to.contains('#')📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Service tokens: if any service is registered, the token endpoint must | ||||||||||||||||||||||||||||
| // know the `aud` it expects on assertions (its own URL). A registry | ||||||||||||||||||||||||||||
| // entry with zero public keys can never authenticate — reject it early. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
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.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: constructorfabric/insight
Length of output: 6468
🏁 Script executed:
Repository: constructorfabric/insight
Length of output: 6468
🏁 Script executed:
Repository: constructorfabric/insight
Length of output: 206
🏁 Script executed:
Repository: constructorfabric/insight
Length of output: 44650
Expose callback rate-limit and internal problem responses in OpenAPI.
The authenticator contract leaves
/auth/callbackas 302 only, whilePRD.mdandDESIGN.mdspecify that rate-limit (429) and internal server errors remain the canonical failure responses and serialize as problem+json. Register the callback’s 429 and internal problem responses with the operation builder and regeneratedocs/components/backend/authenticator/openapi.jsonso generated OpenAPI consumers have the full contract.📍 Affects 2 files
src/backend/services/authenticator/src/api/mod.rs#L87-L93(this comment)docs/components/backend/authenticator/openapi.json#L144-L149🤖 Prompt for AI Agents