Skip to content

Commit

Permalink
sso-proxy: re-factor to help tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danbf committed Oct 10, 2018
1 parent 6fe9d49 commit 774d874
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/proxy/providers/sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,16 @@ func (p *SSOProvider) Redeem(redirectURL, code string) (*SessionState, error) {
params.Add("code", code)
params.Add("grant_type", "authorization_code")

req, err := newRequest("POST", p.ProxyRedeemURL.String(), bytes.NewBufferString(params.Encode()))
// If the hosts dont match use the one in the function call
RedeemURL * url.URL
redirectURLhost, _ := url.Parse(redirectURL)
if redirectURLhost.Host != p.ProxyRedeemURL.Host {
RedeemURL = redirectURL
} else {
RedeemURL = p.ProxyRedeemURL
}

req, err := newRequest("POST", RedeemURL.String(), bytes.NewBufferString(params.Encode()))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 774d874

Please sign in to comment.