From 6a4ab470b4fc87eb8aa249e80ae63629da050295 Mon Sep 17 00:00:00 2001 From: AshersLab Date: Thu, 13 May 2021 15:45:37 +1000 Subject: [PATCH] add to acceptRequest --- internal/hydra/consent.go | 2 +- internal/hydra/hydra.go | 6 +++++- internal/hydra/logout.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/hydra/consent.go b/internal/hydra/consent.go index 1b21f9b..f28c251 100644 --- a/internal/hydra/consent.go +++ b/internal/hydra/consent.go @@ -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") } diff --git a/internal/hydra/hydra.go b/internal/hydra/hydra.go index 2878ec1..a75186c 100644 --- a/internal/hydra/hydra.go +++ b/internal/hydra/hydra.go @@ -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 { diff --git a/internal/hydra/logout.go b/internal/hydra/logout.go index d9cf772..5458482 100644 --- a/internal/hydra/logout.go +++ b/internal/hydra/logout.go @@ -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") }