fix: return 400 instead of 500 on malformed OIDC callbacks#4906
Open
mvanhorn wants to merge 2 commits into
Open
fix: return 400 instead of 500 on malformed OIDC callbacks#4906mvanhorn wants to merge 2 commits into
mvanhorn wants to merge 2 commits into
Conversation
The /authenticate/callback action matched only the known param shapes (provider+code+state, state+code, error+state), so a request with no query string or an unexpected param combination matched no clause and Phoenix raised Phoenix.ActionClauseError, returning a 500. Bare-URL hits from scanners and crawlers turned this into a steady trickle of unhandled exceptions. Add a catch-all new/2 clause that returns a plain 400 Bad Request. Fixes OpenFn#4806
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a 500 on malformed SSO callbacks.
GET /authenticate/callbackis routed toOidcController.new/2, whose clausesonly match the known param shapes (
provider+code+state,state+code,error+state). A request with no query string, or any unexpected paramcombination, matched no clause, so Phoenix raised
Phoenix.ActionClauseErrorand returned a 500. Bare-URL hits from scanners and crawlers made this a steady
trickle of unhandled exceptions.
Added a catch-all
new(conn, _params)clause inlib/lightning_web/controllers/oidc_controller.exthat returns a plain400 Bad Requestinstead of raising.Closes #4806
Validation steps
GET /authenticate/callbackwith no query string and confirm a 400response (previously a 500 with an
ActionClauseError).GET /authenticate/callback?foo=barand confirm a 400 response.state+codestill broadcasts thecode and
error+statestill broadcasts the error.Additional notes for the reviewer
test/lightning_web/controllers/oidc_controller_test.exs. The three validcallback clauses are untouched.
no authorization policies to exercise.
AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code)
(e.g.,
:owner,:admin,:editor,:viewer)AI was used for assistance.