Repository navigation
fix(proxy): set Secure, HttpOnly and SameSite=Strict on the policy selector cookie - #4101
Conversation
…lector cookie Assisted-by: Claude Code:claude-opus-5-5
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 20 |
🟢 Coverage 100.00% diff coverage
Metric Results Coverage variation Report missing for 9afb99f1 Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (9afb99f) Report Missing Report Missing Report Missing Head commit (82d6b0d) 94496 28586 30.25% Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#4101) 6 6 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
pbleser-oc
left a comment
There was a problem hiding this comment.
Looks good to me. Same attributes as the guest session cookie, and the new test fails against the code on main, so it really covers the missing attributes. The notes on plain HTTP and cross-site navigation in the description are helpful.
The red notification pipeline is a connection reset on the settings service (cURL error 18), unrelated to this change.
Description
With a
claimsorregexpolicy selector, the proxy sets theopencloud-selectorcookie on requests with OIDC claims, so that later requests are routed to the same policy. The cookie had noSecure,HttpOnlyorSameSiteattribute. It now has all three:Secure: the browser only sends it over HTTPS.HttpOnly: scripts in the page can't read or change it. No client reads it: only the proxy does.SameSite=Strict: the browser doesn't send it with requests that start on another site.The guest session cookie of the proxy already uses the same attributes.
With the default
staticselector, the proxy sets no selector cookie, so nothing changes for most installations.Related Issue
Motivation and Context
The cookie decides which backend serves a request, and the regex selector uses it before anything else. Without these attributes it was sent over plain HTTP, readable by scripts, and sent with requests from other sites.
Note for installations with a
claimsorregexselector:localhost), the browser drops the cookie. Requests are then routed as if there were no cookie: authenticated requests by the routing claim or the rules, unauthenticated ones by the unauthenticated policy.How Has This Been Tested?
services/proxy/pkg/middleware/selector_cookie_test.go, the first test of this middleware:Path=/,Secure,HttpOnlyandSameSite=Strict. These three cases fail without the fix: the three attributes are missing.go test -race ./services/proxy/...passes.go vetreports nothing new compared withmain.gofmtandgit diff --checkare clean.golangci-lintand the acceptance tests. No acceptance test uses aclaimsorregexselector.Types of changes
Checklist:
AI assistance: Claude Code (claude-opus-5-5) wrote the first draft of the code, the tests and this description; I reviewed and adjusted them.