Limit url to local site (#20013)

Signed-off-by: stonezdj <daojunz@vmware.com>
Co-authored-by: stonezdj <daojunz@vmware.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2024-02-23 15:40:13 +08:00 committed by GitHub
parent fa6b13871f
commit 54819ba8cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -63,7 +63,13 @@ func (oc *OIDCController) RedirectLogin() {
oc.SendInternalServerError(err) oc.SendInternalServerError(err)
return return
} }
if err := oc.SetSession(redirectURLKey, oc.Ctx.Request.URL.Query().Get("redirect_url")); err != nil { redirectURL := oc.Ctx.Request.URL.Query().Get("redirect_url")
if strings.HasPrefix(redirectURL, "//") {
log.Errorf("invalid redirect url: %v", redirectURL)
oc.SendBadRequestError(fmt.Errorf("cannot redirect to other site"))
return
}
if err := oc.SetSession(redirectURLKey, redirectURL); err != nil {
log.Errorf("failed to set session for key: %s, error: %v", redirectURLKey, err) log.Errorf("failed to set session for key: %s, error: %v", redirectURLKey, err)
oc.SendInternalServerError(err) oc.SendInternalServerError(err)
return return