Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions coderd/apikey.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (api *API) createAPIKey(ctx context.Context, params apikey.CreateParams) (*
Value: sessionToken,
Path: "/",
HttpOnly: true,
SameSite: http.SameSiteLaxMode,
Secure: api.SecureAuthCookie,
SameSite: http.SameSiteNoneMode,
Secure: true,
}, &newkey, nil
}
2 changes: 1 addition & 1 deletion coderd/httpmw/csrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
func CSRF(secureCookie bool) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
mw := nosurf.New(next)
mw.SetBaseCookie(http.Cookie{Path: "/", HttpOnly: true, SameSite: http.SameSiteLaxMode, Secure: secureCookie})
mw.SetBaseCookie(http.Cookie{Path: "/", HttpOnly: true, SameSite: http.SameSiteNoneMode, Secure: true})
mw.SetFailureHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
sessCookie, err := r.Cookie(codersdk.SessionTokenCookie)
if err == nil &&
Expand Down
6 changes: 4 additions & 2 deletions coderd/httpmw/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ func ExtractOAuth2(config promoauth.OAuth2Config, client *http.Client, authURLOp
Value: state,
Path: "/",
HttpOnly: true,
SameSite: http.SameSiteLaxMode,
SameSite: http.SameSiteNoneMode,
Secure: true,
})
// Redirect must always be specified, otherwise
// an old redirect could apply!
Expand All @@ -132,7 +133,8 @@ func ExtractOAuth2(config promoauth.OAuth2Config, client *http.Client, authURLOp
Value: redirect,
Path: "/",
HttpOnly: true,
SameSite: http.SameSiteLaxMode,
SameSite: http.SameSiteNoneMode,
Secure: true,
})

http.Redirect(rw, r, config.AuthCodeURL(state, opts...), http.StatusTemporaryRedirect)
Expand Down
4 changes: 2 additions & 2 deletions coderd/userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ func (api *API) postConvertLoginType(rw http.ResponseWriter, r *http.Request) {
Path: "/",
Value: token,
Expires: claims.Expiry.Time(),
Secure: api.SecureAuthCookie,
Secure: true,
HttpOnly: true,
// Must be SameSite to work on the redirected auth flow from the
// oauth provider.
SameSite: http.SameSiteLaxMode,
SameSite: http.SameSiteNoneMode,
})
httpapi.Write(ctx, rw, http.StatusCreated, codersdk.OAuthConversionResponse{
StateString: stateString,
Expand Down