Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Commit

Permalink
Change cookie oidc_nonce to SameSite=None.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommie committed May 27, 2022
1 parent 83bac7d commit 618e18f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions clientapi/routing/sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"net/http"
"net/url"
"path"
"strings"
"time"

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 618e18f

Please sign in to comment.