Skip to content

Commit

Permalink
fix(backend): add correct source header for redirect url
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Urban committed Oct 16, 2023
1 parent c717684 commit e01b9b0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions backend/internal/handlers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,17 @@ func (h *Handler) getRedirectFromCookie(r *http.Request, w http.ResponseWriter)
}
func (h *Handler) getRedirectUrl(r *http.Request) (string, error) {
// Extract the redirect parameter from the request to get the site URL.
printHeaders(r)

siteURL := r.Header.Get("X-Forwarded-Uri")
if siteURL == "" {
siteURL = r.Header.Get("Referer")
}
if siteURL == "" {
siteURL = r.URL.Query().Get("redirect")
if siteURL == "" {
return "", fmt.Errorf("Redirect URL missing from both header and URL parameter")
}
}
if siteURL == "" {
printHeaders(r)
return "", fmt.Errorf("Redirect URL missing from both header and URL parameter")
}
return siteURL, nil
}
Expand Down

0 comments on commit e01b9b0

Please sign in to comment.