Add ability to configure auth redirect url per playground

This commit is contained in:
Marcos Lilljedahl
2020-11-11 23:20:10 -03:00
parent e8486b8100
commit 4b4b767e46
2 changed files with 14 additions and 8 deletions

View File

@@ -73,15 +73,20 @@ func Login(rw http.ResponseWriter, req *http.Request) {
return return
} }
scheme := "http" if playground.AuthRedirectURL != "" {
if req.TLS != nil { provider.RedirectURL = playground.AuthRedirectURL
scheme = "https" } else {
scheme := "http"
if req.TLS != nil {
scheme = "https"
}
host := "localhost"
if req.Host != "" {
host = req.Host
}
provider.RedirectURL = fmt.Sprintf("%s://%s/oauth/providers/%s/callback", scheme, host, providerName)
} }
host := "localhost"
if req.Host != "" {
host = req.Host
}
provider.RedirectURL = fmt.Sprintf("%s://%s/oauth/providers/%s/callback", scheme, host, providerName)
url := provider.AuthCodeURL(loginRequest.Id, oauth2.SetAuthURLParam("nonce", uuid.NewV4().String())) url := provider.AuthCodeURL(loginRequest.Id, oauth2.SetAuthURLParam("nonce", uuid.NewV4().String()))
http.Redirect(rw, req, url, http.StatusFound) http.Redirect(rw, req, url, http.StatusFound)

View File

@@ -88,6 +88,7 @@ type Playground struct {
GoogleClientSecret string `json:"google_client_secret" bson:"google_client_secret"` GoogleClientSecret string `json:"google_client_secret" bson:"google_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"`
AuthRedirectURL string `json:"auth_redirect_url" bson:"auth_redirect_url"`
DockerHost string `json:"docker_host" bson:"docker_host"` DockerHost string `json:"docker_host" bson:"docker_host"`
MaxInstances int `json:"max_instances" bson:"max_instances"` MaxInstances int `json:"max_instances" bson:"max_instances"`
Privileged bool `json:"privileged" bson:"privileged"` Privileged bool `json:"privileged" bson:"privileged"`