Skip to content

Commit

Permalink
fix(saml): respect base url in redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
splaunov committed Oct 14, 2022
1 parent 634ea6f commit 1e09eea
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions selfservice/strategy/saml/strategy/strategy_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package strategy
import (
"bytes"
"encoding/json"
"github.com/ory/x/urlx"
"net/http"
"time"

Expand Down Expand Up @@ -117,10 +118,12 @@ func (s *Strategy) Login(w http.ResponseWriter, r *http.Request, f *login.Flow,
}

if x.IsJSONRequest(r) {
s.d.Writer().WriteError(w, r, flow.NewBrowserLocationChangeRequiredError(handler.RouteSamlLoginInit))
s.d.Writer().WriteError(w, r, flow.NewBrowserLocationChangeRequiredError(urlx.AppendPaths(s.d.Config().SelfPublicURL(r.Context()),
handler.RouteSamlLoginInit).String()))
} else {

http.Redirect(w, r, handler.RouteSamlLoginInit, http.StatusSeeOther)
http.Redirect(w, r,
urlx.AppendPaths(s.d.Config().SelfPublicURL(r.Context()), handler.RouteSamlLoginInit).String(),
http.StatusSeeOther)
}

return nil, errors.WithStack(flow.ErrCompletedByStrategy)
Expand Down

0 comments on commit 1e09eea

Please sign in to comment.