| 12 | ) |
| 13 | |
| 14 | func 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 | |
| 39 | func validateCookieName(name string) []string { |
| 40 | msgs := []string{} |