Skip to content

Commit

Permalink
Limit URL to local site
Browse files Browse the repository at this point in the history
Signed-off-by: stonezdj <[email protected]>
  • Loading branch information
stonezdj committed Feb 23, 2024
1 parent c097e4c commit af92657
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/controllers/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ func (oc *OIDCController) RedirectLogin() {
oc.SendInternalServerError(err)
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 {

Check warning on line 72 in src/core/controllers/oidc.go

View check run for this annotation

Codecov / codecov/patch

src/core/controllers/oidc.go#L66-L72

Added lines #L66 - L72 were not covered by tests
log.Errorf("failed to set session for key: %s, error: %v", redirectURLKey, err)
oc.SendInternalServerError(err)
return
Expand Down

0 comments on commit af92657

Please sign in to comment.