Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions auth_server/authn/tokendb_redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ import (
)

type RedisStoreConfig struct {
ClientOptions *redis.Options `yaml:"redis_options,omitempty"`
ClusterOptions *redis.ClusterOptions `yaml:"redis_cluster_options,omitempty"`
ClientOptions *redis.UniversalOptions `yaml:"redis_options,omitempty"`
TokenHashCost int `yaml:"token_hash_cost,omitempty"`
}

Expand All @@ -45,14 +44,7 @@ type RedisClient interface {
//
func NewRedisTokenDB(options *RedisStoreConfig) (TokenDB, error) {
var client RedisClient
if options.ClusterOptions != nil {
if options.ClientOptions != nil {
glog.Infof("Both redis_token_db.configs and redis_token_db.cluster_configs have been set. Only the latter will be used")
}
client = redis.NewClusterClient(options.ClusterOptions)
} else {
client = redis.NewClient(options.ClientOptions)
}
client = redis.NewUniversalClient(options.ClientOptions)
tokenHashCost := options.TokenHashCost
if tokenHashCost <= 0 {
tokenHashCost = bcrypt.DefaultCost
Expand Down
8 changes: 4 additions & 4 deletions auth_server/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func validate(c *Config) error {
return errors.New("google_auth.{client_id,client_secret,gcs_token_db{bucket,client_secret_file}} are required")
}

if gac.ClientId == "" || gac.ClientSecret == "" || (gac.RedisTokenDB != nil && gac.RedisTokenDB.ClientOptions == nil && gac.RedisTokenDB.ClusterOptions == nil) {
if gac.ClientId == "" || gac.ClientSecret == "" || (gac.RedisTokenDB != nil && gac.RedisTokenDB.ClientOptions == nil) {
return errors.New("google_auth.{client_id,client_secret,redis_token_db.{redis_options,redis_cluster_options}} are required")
}

Expand All @@ -225,7 +225,7 @@ func validate(c *Config) error {
return errors.New("github_auth.{client_id,client_secret,gcs_token_db{bucket,client_secret_file}} are required")
}

if ghac.ClientId == "" || ghac.ClientSecret == "" || (ghac.RedisTokenDB != nil && ghac.RedisTokenDB.ClientOptions == nil && ghac.RedisTokenDB.ClusterOptions == nil) {
if ghac.ClientId == "" || ghac.ClientSecret == "" || (ghac.RedisTokenDB != nil && ghac.RedisTokenDB.ClientOptions == nil) {
return errors.New("github_auth.{client_id,client_secret,redis_token_db.{redis_options,redis_cluster_options}} are required")
}

Expand Down Expand Up @@ -253,7 +253,7 @@ func validate(c *Config) error {
return errors.New("oidc_auth.{client_id,client_secret,gcs_token_db{bucket,client_secret_file}} are required")
}

if oidc.ClientId == "" || oidc.ClientSecret == "" || (oidc.RedisTokenDB != nil && oidc.RedisTokenDB.ClientOptions == nil && oidc.RedisTokenDB.ClusterOptions == nil) {
if oidc.ClientId == "" || oidc.ClientSecret == "" || (oidc.RedisTokenDB != nil && oidc.RedisTokenDB.ClientOptions == nil) {
return errors.New("oidc_auth.{client_id,client_secret,redis_token_db.{redis_options,redis_cluster_options}} are required")
}

Expand Down Expand Up @@ -283,7 +283,7 @@ func validate(c *Config) error {
return errors.New("gitlab_auth.{client_id,client_secret,gcs_token_db{bucket,client_secret_file}} are required")
}

if glab.ClientId == "" || glab.ClientSecret == "" || (glab.RedisTokenDB != nil && glab.RedisTokenDB.ClientOptions == nil && glab.RedisTokenDB.ClusterOptions == nil) {
if glab.ClientId == "" || glab.ClientSecret == "" || (glab.RedisTokenDB != nil && glab.RedisTokenDB.ClientOptions == nil) {
return errors.New("gitlab_auth.{client_id,client_secret,redis_token_db.{redis_options,redis_cluster_options}} are required")
}

Expand Down
20 changes: 12 additions & 8 deletions examples/reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,13 @@ github_auth:
# or Redis,
redis_token_db:
redis_options:
# with a single instance,
addr: localhost:6379
redis_cluster_options:
# or in the cluster mode.
addrs: ["localhost:7000"]
# with a single instance,
addrs: ["localhost:6379"]
# or in the cluster mode.
addrs: ["localhost:7000", "localhost:7001"]
# or in the failover mode with redis sentinel.
mastername: redis-ha
addrs: ["redis-sentinel:26379"]
# How long to wait when talking to GitHub servers. Optional.
http_timeout: "10s"
# How long to wait before revalidating the GitHub token. Optional.
Expand Down Expand Up @@ -232,10 +234,12 @@ gitlab_auth:
redis_token_db:
redis_options:
# with a single instance,
addr: localhost:6379
redis_cluster_options:
addrs: ["localhost:6379"]
# or in the cluster mode.
addrs: ["localhost:7000"]
addrs: ["localhost:7000", "localhost:7001"]
# or in the failover mode with redis sentinel.
mastername: redis-ha
addrs: ["redis-sentinel:26379"]
# How long to wait when talking to GitLab servers. Optional.
http_timeout: "10s"
# How long to wait before revalidating the Gitlab token. Optional.
Expand Down
Loading