Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
Change error code to 422 when redirectBackBase is not whitelisted
Browse files Browse the repository at this point in the history
  • Loading branch information
mrajashree authored and Alena Prokharchyk committed Nov 12, 2018
1 parent ff9cc96 commit 5c0649e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions service/route_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,10 @@ func HandleSamlLogin(w http.ResponseWriter, r *http.Request) {

if !isWhitelisted(redirectBackBaseValue, s.RedirectWhitelist) {
log.Errorf("Cannot redirect to anything other than whitelisted domains and rancher api host")
ReturnHTTPError(w, r, http.StatusForbidden, "Cannot redirect to anything other than whitelisted domains and rancher api host")
redirectBackPathValue := r.URL.Query().Get(redirectBackPath)
redirectURL := server.GetSamlRedirectURL(server.GetRancherAPIHost(), redirectBackPathValue)
redirectURL = addErrorToRedirect(redirectURL, "422")
http.Redirect(w, r, redirectURL, http.StatusFound)
return
}

Expand Down Expand Up @@ -542,7 +545,7 @@ func HandleSamlAssertion(w http.ResponseWriter, r *http.Request, assertion *saml
if !isWhitelisted(redirectBackBaseValue, serviceProvider.RedirectWhitelist) {
log.Errorf("Cannot redirect to anything other than whitelisted domains and rancher api host")
redirectURL := server.GetSamlRedirectURL(server.GetRancherAPIHost(), redirectBackPathValue)
redirectURL = addErrorToRedirect(redirectURL, "403")
redirectURL = addErrorToRedirect(redirectURL, "422")
http.Redirect(w, r, redirectURL, http.StatusFound)
return
}
Expand Down

0 comments on commit 5c0649e

Please sign in to comment.