From de4710ea711e9e405d3024ac41bc147f94ef2981 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 19 Jul 2021 17:19:23 +0200 Subject: [PATCH] outpost: minor cleanup Signed-off-by: Jens Langhammer --- internal/outpost/proxy/cookies.go | 3 +-- internal/outpost/proxy/oauth.go | 5 +---- internal/outpost/proxy/proxy.go | 3 --- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/internal/outpost/proxy/cookies.go b/internal/outpost/proxy/cookies.go index d72b131f7..59045ef16 100644 --- a/internal/outpost/proxy/cookies.go +++ b/internal/outpost/proxy/cookies.go @@ -8,7 +8,6 @@ import ( sessionsapi "github.com/oauth2-proxy/oauth2-proxy/pkg/apis/sessions" "github.com/oauth2-proxy/oauth2-proxy/pkg/cookies" - "github.com/oauth2-proxy/oauth2-proxy/pkg/util" ) // MakeCSRFCookie creates a cookie for CSRF @@ -20,7 +19,7 @@ func (p *OAuthProxy) makeCookie(req *http.Request, name string, value string, ex cookieDomain := cookies.GetCookieDomain(req, p.CookieDomains) if cookieDomain != "" { - domain := util.GetRequestHost(req) + domain := getHost(req) if h, _, err := net.SplitHostPort(domain); err == nil { domain = h } diff --git a/internal/outpost/proxy/oauth.go b/internal/outpost/proxy/oauth.go index 3483a83b0..86b64f9bf 100644 --- a/internal/outpost/proxy/oauth.go +++ b/internal/outpost/proxy/oauth.go @@ -10,7 +10,6 @@ import ( sessionsapi "github.com/oauth2-proxy/oauth2-proxy/pkg/apis/sessions" "github.com/oauth2-proxy/oauth2-proxy/pkg/encryption" - "github.com/oauth2-proxy/oauth2-proxy/pkg/ip" ) // GetRedirectURI returns the redirectURL that the upstream OAuth Provider will @@ -165,8 +164,6 @@ func (p *OAuthProxy) OAuthStart(rw http.ResponseWriter, req *http.Request) { // OAuthCallback is the OAuth2 authentication flow callback that finishes the // OAuth2 authentication flow func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) { - remoteAddr := ip.GetClientString(p.realClientIPParser, req, true) - // finish the oauth cycle err := req.ParseForm() if err != nil { @@ -218,7 +215,7 @@ func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) { p.logger.WithField("user", session.Email).WithField("status", "AuthFailure").Infof("Authenticated via OAuth2: %s", session) err := p.SaveSession(rw, req, session) if err != nil { - p.logger.Printf("Error saving session state for %s: %v", remoteAddr, err) + p.logger.Printf("Error saving session state for client %v", err) p.ErrorPage(rw, http.StatusInternalServerError, "Internal Server Error", err.Error()) return } diff --git a/internal/outpost/proxy/proxy.go b/internal/outpost/proxy/proxy.go index 12c139d6f..414412adc 100644 --- a/internal/outpost/proxy/proxy.go +++ b/internal/outpost/proxy/proxy.go @@ -14,7 +14,6 @@ import ( "github.com/coreos/go-oidc" "github.com/justinas/alice" - ipapi "github.com/oauth2-proxy/oauth2-proxy/pkg/apis/ip" "github.com/oauth2-proxy/oauth2-proxy/pkg/apis/options" sessionsapi "github.com/oauth2-proxy/oauth2-proxy/pkg/apis/sessions" "github.com/oauth2-proxy/oauth2-proxy/pkg/middleware" @@ -91,7 +90,6 @@ type OAuthProxy struct { extraJwtBearerVerifiers []*oidc.IDTokenVerifier compiledRegex []*regexp.Regexp templates *template.Template - realClientIPParser ipapi.RealClientIPParser sessionChain alice.Chain @@ -160,7 +158,6 @@ func NewOAuthProxy(opts *options.Options, provider api.ProxyOutpostConfig, c *ht mainJwtBearerVerifier: opts.GetOIDCVerifier(), extraJwtBearerVerifiers: opts.GetJWTBearerVerifiers(), compiledRegex: opts.GetCompiledRegex(), - realClientIPParser: opts.GetRealClientIPParser(), SetXAuthRequest: opts.SetXAuthRequest, SetBasicAuth: opts.SetBasicAuth, PassUserHeaders: opts.PassUserHeaders,