Fix SSO redirect_uri_mismatch on target subdomains - #1949
Conversation
After upstream warp-tech#1912 refactored construct_external_url to always read the request Host header, SSO redirects from target subdomains (e.g. grafana.warp.example.com) send the wrong redirect_uri to the OAuth provider. Force the SSO return URL to use external_host from config, which is what gets registered in the OAuth provider. Ref: warp-tech#1947
When the SSO callback redirects to the base host (e.g. warp.example.com), the browser was sending a stale host-only session cookie instead of the domain-scoped cookie created on the target subdomain. This caused the state parameter verification to fail against the wrong session. Extend CookieHostMiddleware to also set Domain on cookies for the base host itself, not just strict subdomains. This ensures a single shared session cookie across the base host and all its subdomains.
|
Could you please describe your setup in terms of domains? Do your users always get redirected back to the primary domain when they log in? I'll try to reconcile this with what that change is actually trying to fix: allowing complete SSO flow to happen on the subdomain (with every subdomain having a matching redirect URL registered with SSO) |
|
Assuming your setup is as you described, I think we'll actually need a config flag to switch the behaviour |
|
Basically Warpgate runs on We use subdomain binding so users can:
So that means we have like Cool-application.warpgate.my-domain.com That's why we we are having just warpgate.my-domain.com handle the authentication for these sub-domains, otherwise every time we modify or add one we have to go and update it in google settings. But we have a LOT of these targets, enough that setting every single one as a redirect URL and authorized domain isn't going to be practical |
|
Adding the option in #1971 - would appreciate if you could give it a quick check - |
After upstream #1912 refactored construct_external_url to always read the request Host header, SSO redirects from target subdomains (e.g. grafana.warp.example.com) send the wrong redirect_uri to the OAuth provider. Force the SSO return URL to use external_host from config, which is what gets registered in the OAuth provider.
Ref: warp-tech/warpgate#1947