Repository navigation
feat(authProviders): add SESSION_COOKIE_DOMAIN for cross-subdomain OIDC - #10929
MichaelUray wants to merge 5 commits into
Conversation
|
Connected to Huly®: UBERF-16532 |
|
Pushed a fix for the previous revision (32bde5d), and updated the description. Problem: passing Fix: when Tests: besides the unit matrix for the option decision, a request-level test serves a minimal Koa app over plain HTTP and checks the Secure cross-subdomain session cookie, the opt-out, the unset case and that an explicit |
|
@ArtyomSavchenko gentle ping when you have time: the cookie fix from 2026-10-02 is in, the branch merges cleanly into current |
|
@MichaelUray Please take a look at review comments: Main issues
Smaller points
|
|
Thanks for the detailed review. The requested domain-scoped cookie isolation is The rename has an intentional one-time compatibility effect. The other review changes remain in place:
Formatting passes, and the full |
…n OIDC koa-session defaults the cookie domain to the request host. OIDC flows that start on one subdomain (dev.example.com) and get the callback on another (app.example.com, the host registered with the IdP) lose the Passport state — the cookie set on dev isn't sent to app, so the callback handler errors with 'did not find expected authorization request details in session'. SESSION_COOKIE_DOMAIN=.example.com scopes the cookie to the parent domain so both subdomains share it. Empty / unset preserves the prior behaviour for setups that only use a single host. Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
…domain validation Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
… asserts TLS termination (opt-out SESSION_COOKIE_SECURE=false) With SESSION_COOKIE_DOMAIN set, koa-session was configured with secure: true. The account service listens on plain HTTP behind a TLS-terminating proxy and does not set app.proxy, so Koa builds ctx.cookies with secure: false and the cookies module throws "Cannot send secure cookie over unencrypted connection": /auth/openid answered 500. Setting SESSION_COOKIE_DOMAIN is now treated as the operator's assertion that HTTPS is terminated in front of the service. A small middleware registered before koa-session marks the per-request cookie jar as secure (ctx.cookies.secure = true), so the session cookie is written with Domain, SameSite=Lax and Secure. No forwarded header is trusted: app.proxy stays false and ctx.secure, ctx.host, ctx.request.href and ctx.ip are unchanged. There are no proxy requirements. SESSION_COOKIE_SECURE=false opts out for local plain-HTTP development (domain cookie without Secure, with a warning). Unset or invalid SESSION_COOKIE_DOMAIN keeps the prior behaviour. Cookies written with an explicit secure option keep it, so the login cookie from PUT/DELETE /cookie (secure: ctx.request.secure) is unchanged; only a cookie set without a secure option would now default to Secure, and the account service writes none. Tests: decision matrix for resolveSessionCookieOptions, and request-level tests over plain HTTP (http.createServer + fetch) covering the 302 with Secure session cookie, the explicit/implicit secure behaviour of other cookies, the opt-out, the unset case, and a negative control that reproduces the 500 without the marker. Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
…cumented SESSION_COOKIE_SECURE; address review Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
0e5de3a to
fd27aa2
Compare
|
Rebased onto current |
Summary
Adds explicit configuration for retaining OIDC session state when a login
starts on one subdomain and returns to another.
SESSION_COOKIE_DOMAIN=.example.comscopes the auth session cookie to aparent domain.
huly.sess(and its signature) to avoidcollisions with
koa-sessionapplications on sibling subdomains. WithoutSESSION_COOKIE_DOMAIN, the existing host-scopedkoa.sesskey remains.SESSION_COOKIE_SECUREis an independent option for deployments where TLSterminates before this plain-HTTP process. It accepts
true/false,1/0, andyes/no.SameSite, retaining compatibility with identityproviders that use
response_mode=form_post.termination, and cookie defaults.
Compatibility
SESSION_COOKIE_DOMAINchanges cookie scope only; it does not assert TLS orimplicitly set
SecureorSameSite.Enabling
SESSION_COOKIE_DOMAINalso changes the session key fromkoa.sessto
huly.sess. There is no dual-read or migration: users with an existingsession must sign in again, and in-flight OIDC logins must restart because the
stored state, nonce, and PKCE values remain in the old cookie. Plan this as a
one-time, short-lived login interruption.
Validation
pods/authProviders/node_modules/.bin/format src --force— passed.pods/authProvidersjest — 34 tests passed (cookie-domain unit tests and the session-cookie integration suite).