9 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
10 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
11 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/sessions/redis"
14func validateSessionCookieMinimal(o *options.Options) []string {
15 if !o.Session.Cookie.Minimal {
20 for _, header := range append(o.InjectRequestHeaders, o.InjectResponseHeaders...) {
21 for _, value := range header.Values {
22 if value.ClaimSource != nil {
23 if value.ClaimSource.Claim == "access_token" {
25 fmt.Sprintf("access_token claim for header %q requires oauth tokens in sessions. session_cookie_minimal cannot be set", header.Name))
27 if value.ClaimSource.Claim == "id_token" {
29 fmt.Sprintf("id_token claim for header %q requires oauth tokens in sessions. session_cookie_minimal cannot be set", header.Name))
35 if o.Cookie.Refresh != time.Duration(0) {
37 "cookie_refresh > 0 requires oauth tokens in sessions. session_cookie_minimal cannot be set")
42// validateRedisSessionStore builds a Redis Client from the options and
43// attempts to connect, Set, Get and Del a random health check key
44func validateRedisSessionStore(o *options.Options) []string {
45 if o.Session.Type != options.RedisSessionStoreType {
49 client, err := redis.NewRedisClient(o.Session.Redis)
51 return []string{fmt.Sprintf("unable to initialize a redis client: %v", err)}
54 n, err := encryption.Nonce()
56 return []string{fmt.Sprintf("unable to generate a redis initialization test key: %v", err)}
58 nonce := base64.RawURLEncoding.EncodeToString(n)
60 key := fmt.Sprintf("%s-healthcheck-%s", o.Cookie.Name, nonce)
61 return sendRedisConnectionTest(client, key, nonce)
64func sendRedisConnectionTest(client redis.Client, key string, val string) []string {
66 ctx := context.Background()
68 err := client.Set(ctx, key, []byte(val), time.Duration(60)*time.Second)
70 msgs = append(msgs, fmt.Sprintf("unable to set a redis initialization key: %v", err))
72 gval, err := client.Get(ctx, key)
75 fmt.Sprintf("unable to retrieve redis initialization key: %v", err))
77 if string(gval) != val {
79 "the retrieved redis initialization key did not match the value we set")
83 err = client.Del(ctx, key)
85 msgs = append(msgs, fmt.Sprintf("unable to delete the redis initialization key: %v", err))
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