fix(cas-auth): stop SLO callback POST from being proxied upstream#13610
Open
shreemaan-abhishek wants to merge 1 commit into
Open
fix(cas-auth): stop SLO callback POST from being proxied upstream#13610shreemaan-abhishek wants to merge 1 commit into
shreemaan-abhishek wants to merge 1 commit into
Conversation
A POST to cas_callback_uri carrying a SAML SessionIndex handled the single-logout bookkeeping and then fell through _M.access, returning nil. APISIX treats a nil access result as 'continue', so the IdP logout POST was proxied to the upstream unauthenticated. Terminate the branch with an explicit 200 after handling SLO, and add a regression test asserting the callback POST never reaches the upstream.
There was a problem hiding this comment.
Pull request overview
This PR fixes a control-flow bug in the cas-auth plugin where a CAS IdP single-logout (SLO) POST to cas_callback_uri could be unintentionally proxied to the upstream due to the SLO branch falling through the access handler. The change ensures the plugin fully terminates the SLO callback request and never forwards it upstream.
Changes:
- Terminate the SLO
POSTcallback path incas-authwith an explicitreturn ngx.HTTP_OK. - Add a regression test that would fail with a
502if the request were still being proxied to a closed upstream port. - Document that SLO
POSTcallbacks are handled by the plugin and not forwarded upstream.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apisix/plugins/cas-auth.lua | Adds an explicit return ngx.HTTP_OK to stop SLO callback POST requests from falling through to upstream proxying. |
| t/plugin/cas-auth.t | Adds a regression test route with a closed-port upstream and asserts SLO POST returns 200 from the plugin (not 502). |
| docs/en/latest/plugins/cas-auth.md | Documents that SLO POST callbacks to cas_callback_uri are handled by the plugin and not forwarded upstream. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
membphis
approved these changes
Jun 26, 2026
nic-6443
approved these changes
Jun 26, 2026
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
The
cas-authplugin protects routes and also captures the configuredcas_callback_uriso it can handle the IdP's single-logout (SLO)POSTcallback.In
_M.access, the SLOPOSTbranch parses the SAMLSessionIndex, optionally deletes the matching session, and then falls through the function. Because the branch has no terminatingreturn,_M.accessreturnsnil, which APISIX treats as "continue the phase chain", so the IdP's logoutPOSTis proxied to the upstream unauthenticated.This patch ends the SLO branch with an explicit
return ngx.HTTP_OKafter the logout bookkeeping, so the callbackPOSTis fully handled by the plugin and never reaches the upstream.Fixes
apisix/plugins/cas-auth.lua: terminate the SLOPOSTbranch with200.t/plugin/cas-auth.t: regression test sending a well-formed SLOPOSTto a route whose upstream is a closed port; it must return200from the plugin rather than a502from a fall-through proxy attempt.docs/en/latest/plugins/cas-auth.md: document that SLOPOSTcallbacks are handled by the plugin and not forwarded upstream.Checklist