8 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
9 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
12func validateCookie(o options.Cookie) []string {
13 msgs := validateCookieSecret(o.Secret)
15 if o.Refresh >= o.Expire {
16 msgs = append(msgs, fmt.Sprintf(
17 "cookie_refresh (%q) must be less than cookie_expire (%q)",
23 case "", "none", "lax", "strict":
25 msgs = append(msgs, fmt.Sprintf("cookie_samesite (%q) must be one of ['', 'lax', 'strict', 'none']", o.SameSite))
28 // Sort cookie domains by length, so that we try longer (and more specific) domains first
29 sort.Slice(o.Domains, func(i, j int) bool {
30 return len(o.Domains[i]) > len(o.Domains[j])
33 msgs = append(msgs, validateCookieName(o.Name)...)
37func validateCookieName(name string) []string {
40 cookie := &http.Cookie{Name: name}
41 if cookie.String() == "" {
42 msgs = append(msgs, fmt.Sprintf("invalid cookie name: %q", name))
46 msgs = append(msgs, fmt.Sprintf("cookie name should be under 256 characters: cookie name is %d characters", len(name)))
51func validateCookieSecret(secret string) []string {
53 return []string{"missing setting: cookie-secret"}
56 secretBytes := encryption.SecretBytes(secret)
57 // Check if the secret is a valid length
58 switch len(secretBytes) {
60 // Valid secret size found
63 // Invalid secret size found, return a message
64 return []string{fmt.Sprintf(
65 "cookie_secret must be 16, 24, or 32 bytes to create an AES cipher, but is %d bytes",
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list