You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "shreemaan-abhishek (via GitHub)" <gi...@apache.org> on 2026/05/05 13:46:00 UTC

[PR] feat(cas-auth): sign request URI cookie and tighten cookie attributes [apisix]

shreemaan-abhishek opened a new pull request, #13331:
URL: https://github.com/apache/apisix/pull/13331

   ### Description
   
   This change updates the `cas-auth` plugin so that the `CAS_REQUEST_URI` cookie — which the plugin uses to remember where the user was headed before being bounced to the CAS IdP — is signed with HMAC-SHA256 and verified on the IdP callback using a constant-time comparison.
   
   After successful CAS ticket validation, the recovered redirect target is also validated as a same-origin path before being applied; if the cookie is missing, malformed, fails signature verification, or carries something that is not a relative path, the plugin falls back to `/` instead of using the cookie value verbatim.
   
   Cookie attributes are tightened: `Secure; SameSite=Lax` are added to the existing `Path=/; HttpOnly`.
   
   A new required `cookie_secret` field (minLength 32) is added to the plugin schema. The same value must be configured on every APISIX node in the deployment so that signed cookies issued by one node remain verifiable on another. The `t/lib/keycloak_cas.lua` test helper is updated so existing integration tests continue to pass.
   
   #### Which issue(s) this PR fixes:
   
   N/A
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [ ] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(cas-auth): sign request URI cookie and tighten cookie attributes [apisix]

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on PR #13331:
URL: https://github.com/apache/apisix/pull/13331#issuecomment-4428977866

   @membphis updated the PR description with a **Breaking change** section that:
   
   - Calls out the incompatibility explicitly at the top
   - Explains why `cookie.secret` is required rather than optional (the integrity invariant only holds if *every* issued cookie is signed; making it optional would defeat the guarantee for unconfigured routes)
   - Provides a concrete before/after JSON migration example
   - Notes the rolling-upgrade operational impact (update configs first, then roll out the binary)
   
   Happy to add anything else if there's a specific deployment concern you want covered.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(cas-auth): sign request URI cookie and tighten cookie attributes [apisix]

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek merged PR #13331:
URL: https://github.com/apache/apisix/pull/13331


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(cas-auth): sign request URI cookie and tighten cookie attributes [apisix]

Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan commented on code in PR #13331:
URL: https://github.com/apache/apisix/pull/13331#discussion_r3256100935


##########
apisix/plugins/cas-auth.lua:
##########
@@ -35,23 +38,54 @@ local schema = {
         idp_uri = {type = "string"},
         cas_callback_uri = {type = "string"},
         logout_uri = {type = "string"},
+        cookie = {
+            type = "object",
+            properties = {
+                secret = {type = "string", minLength = 32},
+                secure = {type = "boolean", default = true},
+                samesite = {type = "string", enum = {"Lax", "None"}, default = "Lax"},
+            },
+            required = {"secret"},

Review Comment:
   Perhaps we can consider automatically generating when cookie.secre is empty to avoid destructive changes?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(cas-auth): sign request URI cookie and tighten cookie attributes [apisix]

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on PR #13331:
URL: https://github.com/apache/apisix/pull/13331#issuecomment-4428456312

   @membphis it is mentioned at the end of the PR description that it is not backward compatible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(cas-auth): sign request URI cookie and tighten cookie attributes [apisix]

Posted by "nic-6443 (via GitHub)" <gi...@apache.org>.
nic-6443 commented on code in PR #13331:
URL: https://github.com/apache/apisix/pull/13331#discussion_r3247311735


##########
docs/en/latest/plugins/cas-auth.md:
##########
@@ -64,7 +68,10 @@ curl http://127.0.0.1:9180/apisix/admin/routes/cas1 -H "X-API-KEY: $admin_key" -
           "cas-auth": {
               "idp_uri": "http://127.0.0.1:8080/realms/test/protocol/cas",
               "cas_callback_uri": "/anything/cas_callback",
-              "logout_uri": "/anything/logout"
+              "logout_uri": "/anything/logout",
+              "cookie": {
+                  "secret": "please-replace-with-a-32+-char-random-secret"

Review Comment:
   This example still runs the protected route over `http://127.0.0.1`, but the new default is `cookie.secure=true`. Browsers will ignore both `CAS_REQUEST_URI` and `CAS_SESSION` when they are set with `Secure` over HTTP, so following this example would either fall back to `/` after login or fail to keep the session cookie. Can we either add `"secure": false` here for the local HTTP example, or switch the example to HTTPS?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(cas-auth): sign request URI cookie and tighten cookie attributes [apisix]

Posted by "membphis (via GitHub)" <gi...@apache.org>.
membphis commented on PR #13331:
URL: https://github.com/apache/apisix/pull/13331#issuecomment-4428567450

   > @membphis it is mentioned at the end of the PR description that it is not backward compatible.
   
   only this is not enough, pls write some detail doc about the `not backward compatible`
   
   <img width="787" height="676" alt="image" src="https://github.com/user-attachments/assets/8269961c-8e99-4b0c-b25e-7ffb6fafc2ec" />
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(cas-auth): sign request URI cookie and tighten cookie attributes [apisix]

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on code in PR #13331:
URL: https://github.com/apache/apisix/pull/13331#discussion_r3256279310


##########
apisix/plugins/cas-auth.lua:
##########
@@ -35,23 +38,54 @@ local schema = {
         idp_uri = {type = "string"},
         cas_callback_uri = {type = "string"},
         logout_uri = {type = "string"},
+        cookie = {
+            type = "object",
+            properties = {
+                secret = {type = "string", minLength = 32},
+                secure = {type = "boolean", default = true},
+                samesite = {type = "string", enum = {"Lax", "None"}, default = "Lax"},
+            },
+            required = {"secret"},

Review Comment:
   It doesn't avoid the breaking change in practice 🤔. In multi-node deployment scenario, the cookie would be set on the pre-redirect request but verified on the IdP callback, which can land on a different node. If each node generates its own secret, verification fails across nodes and on every reload, so CAS login silently breaks instead of the config being loudly rejected.
   
   Also how can we persist such autogenerated cookie?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(cas-auth): sign request URI cookie and tighten cookie attributes [apisix]

Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan commented on code in PR #13331:
URL: https://github.com/apache/apisix/pull/13331#discussion_r3256100935


##########
apisix/plugins/cas-auth.lua:
##########
@@ -35,23 +38,54 @@ local schema = {
         idp_uri = {type = "string"},
         cas_callback_uri = {type = "string"},
         logout_uri = {type = "string"},
+        cookie = {
+            type = "object",
+            properties = {
+                secret = {type = "string", minLength = 32},
+                secure = {type = "boolean", default = true},
+                samesite = {type = "string", enum = {"Lax", "None"}, default = "Lax"},
+            },
+            required = {"secret"},

Review Comment:
   Perhaps we can consider automatically generating when `cookie.secret` is empty to avoid destructive changes?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org