mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-07 06:03:09 -06:00
Change cookie oidc_nonce to SameSite=None.
https://github.com/matrix-org/dendrite/issues/1297#issuecomment-1139357227
This commit is contained in:
parent
83bac7df36
commit
618e18f259
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -89,14 +90,20 @@ func SSORedirect(
|
|||
util.GetLogger(ctx).Infof("SSO redirect to %s.", u)
|
||||
|
||||
resp := util.RedirectResponse(u)
|
||||
resp.Headers["Set-Cookie"] = (&http.Cookie{
|
||||
cookie := &http.Cookie{
|
||||
Name: "oidc_nonce",
|
||||
Value: nonce,
|
||||
Path: "/",
|
||||
Path: path.Dir(callbackURL.Path),
|
||||
Expires: time.Now().Add(10 * time.Minute),
|
||||
Secure: callbackURL.Scheme != "http",
|
||||
SameSite: http.SameSiteStrictMode,
|
||||
}).String()
|
||||
SameSite: http.SameSiteNoneMode,
|
||||
}
|
||||
if !cookie.Secure {
|
||||
// SameSite=None requires Secure, so we might as well remove
|
||||
// it. See https://blog.chromium.org/2019/10/developers-get-ready-for-new.html.
|
||||
cookie.SameSite = http.SameSiteDefaultMode
|
||||
}
|
||||
resp.Headers["Set-Cookie"] = cookie.String()
|
||||
return resp
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue