Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: proper SameSite=None in dev mode #3502

Merged
merged 1 commit into from
Apr 29, 2023
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
3 changes: 2 additions & 1 deletion driver/config/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ func (p *DefaultProvider) CookieSameSiteMode(ctx context.Context) http.SameSite
case "strict":
return http.SameSiteStrictMode
case "none":
if p.IsDevelopmentMode(ctx) {
hperl marked this conversation as resolved.
Show resolved Hide resolved
if p.IssuerURL(ctx).Scheme != "https" {
// SameSite=None can only be set for HTTPS issuers.
return http.SameSiteLaxMode
}
return http.SameSiteNoneMode
Expand Down
9 changes: 9 additions & 0 deletions driver/config/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,20 @@ func TestProviderCookieSameSiteMode(t *testing.T) {
p.MustSet(ctx, KeyCookieSameSiteMode, "none")
assert.Equal(t, http.SameSiteNoneMode, p.CookieSameSiteMode(ctx))

p.MustSet(ctx, KeyCookieSameSiteMode, "lax")
assert.Equal(t, http.SameSiteLaxMode, p.CookieSameSiteMode(ctx))

p.MustSet(ctx, KeyCookieSameSiteMode, "strict")
assert.Equal(t, http.SameSiteStrictMode, p.CookieSameSiteMode(ctx))

p = MustNew(context.Background(), l, configx.SkipValidation())
p.MustSet(ctx, "dev", true)
assert.Equal(t, http.SameSiteLaxMode, p.CookieSameSiteMode(ctx))
p.MustSet(ctx, KeyCookieSameSiteMode, "none")
assert.Equal(t, http.SameSiteLaxMode, p.CookieSameSiteMode(ctx))

p.MustSet(ctx, KeyIssuerURL, "https://example.com")
assert.Equal(t, http.SameSiteNoneMode, p.CookieSameSiteMode(ctx))
}

func TestViperProviderValidates(t *testing.T) {
Expand Down