add to acceptRequest

This commit is contained in:
AshersLab 2021-05-13 15:45:37 +10:00 committed by Nikolay Stupak
parent 67c63ca8cd
commit 6a4ab470b4
3 changed files with 7 additions and 3 deletions

View File

@ -47,6 +47,6 @@ func (crd *ConsentReqDoer) AcceptConsentRequest(challenge string, remember bool,
IDToken: idToken,
},
}
redirectURI, err := acceptRequest(consent, crd.hydraURL, challenge, data)
redirectURI, err := acceptRequest(consent, crd.hydraURL, crd.fakeTlsTermination, challenge, data)
return redirectURI, errors.Wrap(err, "failed to accept consent request")
}

View File

@ -85,7 +85,7 @@ func initiateRequest(typ reqType, hydraURL string, fakeTlsTermination bool, chal
return &ri, nil
}
func acceptRequest(typ reqType, hydraURL, challenge string, data interface{}) (string, error) {
func acceptRequest(typ reqType, hydraURL string, fakeTlsTermination bool, challenge string, data interface{}) (string, error) {
if challenge == "" {
return "", ErrChallengeMissed
}
@ -110,6 +110,10 @@ func acceptRequest(typ reqType, hydraURL, challenge string, data interface{}) (s
if err != nil {
return "", err
}
if fakeTlsTermination {
r.Header.Add("X-Forwarded-Proto", "https")
}
r.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(r)
if err != nil {

View File

@ -30,6 +30,6 @@ func (lrd *LogoutReqDoer) InitiateRequest(challenge string) (*ReqInfo, error) {
// AcceptLogoutRequest accepts the requested logout process, and returns redirect URI.
func (lrd *LogoutReqDoer) AcceptLogoutRequest(challenge string) (string, error) {
redirectURI, err := acceptRequest(logout, lrd.hydraURL, challenge, nil)
redirectURI, err := acceptRequest(logout, lrd.hydraURL, lrd.fakeTlsTermination, challenge, nil)
return redirectURI, errors.Wrap(err, "failed to accept logout request")
}