Make docker Oauth endpoint configurable

This commit is contained in:
Marcos Lilljedahl
2019-03-31 14:14:05 -03:00
parent 91912732aa
commit 40197c4cdf
2 changed files with 8 additions and 3 deletions

View File

@@ -240,14 +240,18 @@ func initOauthProviders(p *types.Playground) {
config.Providers[p.Id]["facebook"] = conf config.Providers[p.Id]["facebook"] = conf
} }
if p.DockerClientID != "" && p.DockerClientSecret != "" { if p.DockerClientID != "" && p.DockerClientSecret != "" {
oauth2.RegisterBrokenAuthHeaderProvider(".id.docker.com") endpoint := "id.docker.com"
if len(p.DockerHost) > 0 {
endpoint = p.DockerHost
}
oauth2.RegisterBrokenAuthHeaderProvider(fmt.Sprintf(".%s", endpoint))
conf := &oauth2.Config{ conf := &oauth2.Config{
ClientID: p.DockerClientID, ClientID: p.DockerClientID,
ClientSecret: p.DockerClientSecret, ClientSecret: p.DockerClientSecret,
Scopes: []string{"openid"}, Scopes: []string{"openid"},
Endpoint: oauth2.Endpoint{ Endpoint: oauth2.Endpoint{
AuthURL: "https://id.docker.com/id/oauth/authorize/", AuthURL: fmt.Sprintf("https://%s/id/oauth/authorize/", endpoint),
TokenURL: "https://id.docker.com/id/oauth/token", TokenURL: fmt.Sprintf("https://%s/id/oauth/token", endpoint),
}, },
} }

View File

@@ -87,5 +87,6 @@ type Playground struct {
FacebookClientSecret string `json:"facebook_client_secret" bson:"facebook_client_secret"` FacebookClientSecret string `json:"facebook_client_secret" bson:"facebook_client_secret"`
DockerClientID string `json:"docker_client_id" bson:"docker_client_id"` DockerClientID string `json:"docker_client_id" bson:"docker_client_id"`
DockerClientSecret string `json:"docker_client_secret" bson:"docker_client_secret"` DockerClientSecret string `json:"docker_client_secret" bson:"docker_client_secret"`
DockerHost string `json:"docker_host" bson:"docker_host"`
MaxInstances int `json:"max_instances" bson:"max_instances"` MaxInstances int `json:"max_instances" bson:"max_instances"`
} }