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
}
scheme := "http"
if req.TLS != nil {
scheme = "https"
if playground.AuthRedirectURL != "" {
provider.RedirectURL = playground.AuthRedirectURL
} 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()))
http.Redirect(rw, req, url, http.StatusFound)