Skip to content

Commit

Permalink
Merge pull request Versent#846 from dboitnot/adfs-fix
Browse files Browse the repository at this point in the history
fix Versentgh-845: handle relative URL in authSubmitURL
  • Loading branch information
wolfeidau authored Jul 21, 2022
2 parents e2a85d2 + fe50b20 commit 86e686d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/provider/adfs/adfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ func (ac *Client) Authenticate(loginDetails *creds.LoginDetails) (string, error)

if authSubmitURL == "" {
return samlAssertion, fmt.Errorf("unable to locate IDP authentication form submit URL")
} else if strings.HasPrefix(authSubmitURL, "/") {
//
// The server returned a relative URL. Make it absolute.
//
parsedUrl, err := url.Parse(adfsURL)
if err != nil {
return "", errors.Wrap(err, "failed to parse ADFS URL")
}
parsedPath, err := url.Parse(authSubmitURL)
if err != nil {
return "", errors.Wrap(err, "failed to parse authSubmitURL fragment")
}
authSubmitURL = parsedUrl.ResolveReference(parsedPath).String()
}

doc, err = ac.submit(authSubmitURL, authForm)
Expand Down

0 comments on commit 86e686d

Please sign in to comment.