mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 04:52:35 +02:00
fix(oidc): simplify and fix oidc middleware url handling
This commit is contained in:
parent
8f03662982
commit
36fab0cd50
1 changed files with 5 additions and 10 deletions
|
@ -201,17 +201,12 @@ func (auth *OIDCProvider) RedirectLoginPage(w http.ResponseWriter, r *http.Reque
|
||||||
Path: "/",
|
Path: "/",
|
||||||
})
|
})
|
||||||
|
|
||||||
redirURL := auth.oauthConfig.AuthCodeURL(state)
|
var redirURL string
|
||||||
if auth.isMiddleware {
|
if auth.isMiddleware {
|
||||||
u, err := r.URL.Parse(redirURL)
|
optOverrideRedirectURL := oauth2.SetAuthURLParam("redirect_uri", "https://"+r.Host+OIDCMiddlewareCallbackPath)
|
||||||
if err != nil {
|
redirURL = auth.oauthConfig.AuthCodeURL(state, optOverrideRedirectURL)
|
||||||
gphttp.ServerError(w, r, err)
|
} else {
|
||||||
return
|
redirURL = auth.oauthConfig.AuthCodeURL(state)
|
||||||
}
|
|
||||||
q := u.Query()
|
|
||||||
q.Set("redirect_uri", "https://"+r.Host+OIDCMiddlewareCallbackPath+q.Get("redirect_uri"))
|
|
||||||
u.RawQuery = q.Encode()
|
|
||||||
redirURL = u.String()
|
|
||||||
}
|
}
|
||||||
http.Redirect(w, r, redirURL, http.StatusTemporaryRedirect)
|
http.Redirect(w, r, redirURL, http.StatusTemporaryRedirect)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue