feat(cookie): change SameSiteMode and ScriptAccess enum values to PascalCasing

Signed-off-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
Jan Larwig
2026-03-26 22:24:21 +01:00
parent d01b06310e
commit d9a31198ab
6 changed files with 32 additions and 20 deletions
+2 -2
View File
@@ -21,9 +21,9 @@ func validateCookie(o options.Cookie, refresh time.Duration) []string {
}
switch o.SameSite {
case "", "none", "lax", "strict":
case options.SameSiteLax, options.SameSiteStrict, options.SameSiteNone, options.SameSiteDefault:
default:
msgs = append(msgs, fmt.Sprintf("cookie_samesite (%q) must be one of ['', 'lax', 'strict', 'none']", o.SameSite))
msgs = append(msgs, fmt.Sprintf("cookie_samesite (%q) must be one of ['', 'Lax', 'Strict', 'None']", o.SameSite))
}
// Sort cookie domains by length, so that we try longer (and more specific) domains first
+4 -4
View File
@@ -63,7 +63,7 @@ func TestValidateCookie(t *testing.T) {
invalidSecretMsg := "cookie_secret must be 16, 24, or 32 bytes to create an AES cipher, but is 6 bytes"
invalidBase64SecretMsg := "cookie_secret must be 16, 24, or 32 bytes to create an AES cipher, but is 10 bytes"
refreshLongerThanExpireMsg := "cookie_refresh (\"1h0m0s\") must be less than cookie_expire (\"15m0s\")"
invalidSameSiteMsg := "cookie_samesite (\"invalid\") must be one of ['', 'lax', 'strict', 'none']"
invalidSameSiteMsg := "cookie_samesite (\"invalid\") must be one of ['', 'Lax', 'Strict', 'None']"
testCases := []struct {
name string
@@ -216,7 +216,7 @@ func TestValidateCookie(t *testing.T) {
Expire: time.Hour,
Insecure: ptr.To(false),
ScriptAccess: options.ScriptAccessAllowed,
SameSite: "none",
SameSite: options.SameSiteNone,
},
refresh: 15 * time.Minute,
errStrings: []string{},
@@ -231,7 +231,7 @@ func TestValidateCookie(t *testing.T) {
Expire: time.Hour,
Insecure: ptr.To(false),
ScriptAccess: options.ScriptAccessAllowed,
SameSite: "none",
SameSite: options.SameSiteLax,
},
refresh: 15 * time.Minute,
errStrings: []string{},
@@ -246,7 +246,7 @@ func TestValidateCookie(t *testing.T) {
Expire: time.Hour,
Insecure: ptr.To(false),
ScriptAccess: options.ScriptAccessAllowed,
SameSite: "none",
SameSite: options.SameSiteStrict,
},
refresh: 15 * time.Minute,
errStrings: []string{},