MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / validateCookie

Function validateCookie

pkg/validation/cookie.go:14–37  ·  view source on GitHub ↗
(o options.Cookie)

Source from the content-addressed store, hash-verified

12)
13
14func validateCookie(o options.Cookie) []string {
15 msgs := validateCookieSecret(o.Secret, o.SecretFile)
16
17 if o.Expire != time.Duration(0) && o.Refresh >= o.Expire {
18 msgs = append(msgs, fmt.Sprintf(
19 "cookie_refresh (%q) must be less than cookie_expire (%q)",
20 o.Refresh.String(),
21 o.Expire.String()))
22 }
23
24 switch o.SameSite {
25 case "", "none", "lax", "strict":
26 default:
27 msgs = append(msgs, fmt.Sprintf("cookie_samesite (%q) must be one of ['', 'lax', 'strict', 'none']", o.SameSite))
28 }
29
30 // Sort cookie domains by length, so that we try longer (and more specific) domains first
31 sort.Slice(o.Domains, func(i, j int) bool {
32 return len(o.Domains[i]) > len(o.Domains[j])
33 })
34
35 msgs = append(msgs, validateCookieName(o.Name)...)
36 return msgs
37}
38
39func validateCookieName(name string) []string {
40 msgs := []string{}

Callers 2

ValidateFunction · 0.85
TestValidateCookieFunction · 0.85

Calls 3

validateCookieSecretFunction · 0.85
validateCookieNameFunction · 0.85
StringMethod · 0.45

Tested by 1

TestValidateCookieFunction · 0.68