diff options
author | Joram Wilander <jwawilander@gmail.com> | 2018-07-31 10:29:19 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2018-07-31 07:29:19 -0700 |
commit | 867416b0e6281059d79e100f3019fe2a2f4c2753 (patch) | |
tree | 4e83cc2a4e108237c40a5f8093ee00532dd6ed30 /api4 | |
parent | 709101c4df903e94c5eb954640ce8f6da98cedef (diff) | |
download | chat-867416b0e6281059d79e100f3019fe2a2f4c2753.tar.gz chat-867416b0e6281059d79e100f3019fe2a2f4c2753.tar.bz2 chat-867416b0e6281059d79e100f3019fe2a2f4c2753.zip |
Add OAuth2 login hint for SAML (#9194)
Diffstat (limited to 'api4')
-rw-r--r-- | api4/oauth.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/api4/oauth.go b/api4/oauth.go index ab4b1bfcf..d747e3422 100644 --- a/api4/oauth.go +++ b/api4/oauth.go @@ -332,6 +332,8 @@ func authorizeOAuthPage(c *Context, w http.ResponseWriter, r *http.Request) { State: r.URL.Query().Get("state"), } + loginHint := r.URL.Query().Get("login_hint") + if err := authRequest.IsValid(); err != nil { utils.RenderWebAppError(c.App.Config(), w, r, err, c.App.AsymmetricSigningKey()) return @@ -345,7 +347,11 @@ func authorizeOAuthPage(c *Context, w http.ResponseWriter, r *http.Request) { // here we should check if the user is logged in if len(c.Session.UserId) == 0 { - http.Redirect(w, r, c.GetSiteURLHeader()+"/login?redirect_to="+url.QueryEscape(r.RequestURI), http.StatusFound) + if loginHint == model.USER_AUTH_SERVICE_SAML { + http.Redirect(w, r, c.GetSiteURLHeader()+"/login/sso/saml?redirect_to="+url.QueryEscape(r.RequestURI), http.StatusFound) + } else { + http.Redirect(w, r, c.GetSiteURLHeader()+"/login?redirect_to="+url.QueryEscape(r.RequestURI), http.StatusFound) + } return } |