@@ -29,7 +29,6 @@ import (
2929 "time"
3030
3131 "github.com/cesanta/glog"
32- "github.com/go-redis/redis"
3332
3433 "github.com/cesanta/docker_auth/auth_server/api"
3534)
@@ -57,20 +56,20 @@ type ParentGitlabTeam struct {
5756}
5857
5958type GitlabAuthConfig struct {
60- Organization string `yaml:"organization,omitempty"`
61- ClientId string `yaml:"client_id,omitempty"`
62- ClientSecret string `yaml:"client_secret,omitempty"`
63- ClientSecretFile string `yaml:"client_secret_file,omitempty"`
64- TokenDB string `yaml:"token_db ,omitempty"`
65- GCSTokenDB * GitlabGCSStoreConfig `yaml:"gcs_token_db,omitempty"`
66- RedisTokenDB * GitlabRedisStoreConfig `yaml:"redis_token_db,omitempty"`
67- HTTPTimeout time.Duration `yaml:"http_timeout,omitempty"`
68- RevalidateAfter time.Duration `yaml:"revalidate_after,omitempty"`
69- GitlabWebUri string `yaml:"gitlab_web_uri,omitempty"`
70- GitlabApiUri string `yaml:"gitlab_api_uri,omitempty"`
71- RegistryUrl string `yaml:"registry_url,omitempty"`
72- GrantType string `yaml:"grant_type,omitempty"`
73- RedirectUri string `yaml:"redirect_uri,omitempty"`
59+ Organization string `yaml:"organization,omitempty"`
60+ ClientId string `yaml:"client_id,omitempty"`
61+ ClientSecret string `yaml:"client_secret,omitempty"`
62+ ClientSecretFile string `yaml:"client_secret_file,omitempty"`
63+ LevelTokenDB * LevelDBStoreConfig `yaml:"level_token_db ,omitempty"`
64+ GCSTokenDB * GCSStoreConfig `yaml:"gcs_token_db,omitempty"`
65+ RedisTokenDB * RedisStoreConfig `yaml:"redis_token_db,omitempty"`
66+ HTTPTimeout time.Duration `yaml:"http_timeout,omitempty"`
67+ RevalidateAfter time.Duration `yaml:"revalidate_after,omitempty"`
68+ GitlabWebUri string `yaml:"gitlab_web_uri,omitempty"`
69+ GitlabApiUri string `yaml:"gitlab_api_uri,omitempty"`
70+ RegistryUrl string `yaml:"registry_url,omitempty"`
71+ GrantType string `yaml:"grant_type,omitempty"`
72+ RedirectUri string `yaml:"redirect_uri,omitempty"`
7473}
7574
7675type CodeToGitlabTokenResponse struct {
@@ -85,16 +84,6 @@ type CodeToGitlabTokenResponse struct {
8584 ErrorDescription string `json:"error_description,omitempty"`
8685}
8786
88- type GitlabGCSStoreConfig struct {
89- Bucket string `yaml:"bucket,omitempty"`
90- ClientSecretFile string `yaml:"client_secret_file,omitempty"`
91- }
92-
93- type GitlabRedisStoreConfig struct {
94- ClientOptions * redis.Options `yaml:"redis_options,omitempty"`
95- ClusterOptions * redis.ClusterOptions `yaml:"redis_cluster_options,omitempty"`
96- }
97-
9887type GitlabAuthRequest struct {
9988 Action string `json:"action,omitempty"`
10089 Code string `json:"code,omitempty"`
@@ -118,17 +107,18 @@ type GitlabAuth struct {
118107func NewGitlabAuth (c * GitlabAuthConfig ) (* GitlabAuth , error ) {
119108 var db TokenDB
120109 var err error
121- dbName := c . TokenDB
110+ var dbName string
122111
123112 switch {
124113 case c .GCSTokenDB != nil :
125- db , err = NewGCSTokenDB (c .GCSTokenDB . Bucket , c . GCSTokenDB . ClientSecretFile )
114+ db , err = NewGCSTokenDB (c .GCSTokenDB )
126115 dbName = "GCS: " + c .GCSTokenDB .Bucket
127116 case c .RedisTokenDB != nil :
128- db , err = NewRedisGitlabTokenDB (c .RedisTokenDB )
117+ db , err = NewRedisTokenDB (c .RedisTokenDB )
129118 dbName = db .(* redisTokenDB ).String ()
130119 default :
131- db , err = NewTokenDB (c .TokenDB )
120+ db , err = NewTokenDB (c .LevelTokenDB )
121+ dbName = c .LevelTokenDB .Path
132122 }
133123
134124 if err != nil {
@@ -140,7 +130,7 @@ func NewGitlabAuth(c *GitlabAuthConfig) (*GitlabAuth, error) {
140130 return & GitlabAuth {
141131 config : c ,
142132 db : db ,
143- client : & http.Client {Timeout : 10 * time . Second },
133+ client : & http.Client {Timeout : c . HTTPTimeout },
144134 tmpl : template .Must (template .New ("gitlab_auth" ).Parse (string (gitlab_auth ))),
145135 tmplResult : template .Must (template .New ("gitlab_auth_result" ).Parse (string (gitlab_auth_result ))),
146136 }, nil
0 commit comments