From 67f8234f284d15b26eb2bc8d3aa5a064d47c7d19 Mon Sep 17 00:00:00 2001 From: Tarun Gupta Akirala Date: Thu, 19 Aug 2021 02:08:42 -0700 Subject: [PATCH] feat: initialize http client explicitly when calling go-oidc provider (#45) --- internal/configuration/config.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/configuration/config.go b/internal/configuration/config.go index 2e622ab..f15d2a8 100644 --- a/internal/configuration/config.go +++ b/internal/configuration/config.go @@ -6,9 +6,9 @@ import ( "encoding/json" "errors" "fmt" - "github.com/mesosphere/traefik-forward-auth/internal/util" "io" "io/ioutil" + "net/http" "os" "regexp" "strconv" @@ -20,6 +20,7 @@ import ( "github.com/thomseddon/go-flags" internallog "github.com/mesosphere/traefik-forward-auth/internal/log" + "github.com/mesosphere/traefik-forward-auth/internal/util" ) var ( @@ -93,6 +94,10 @@ func NewConfig(args []string) (*Config, error) { err := c.parseFlags(args) + // Set the client context explicitly in order to use proxy configuration from environment(if any) + // See https://github.com/coreos/go-oidc/blob/8d771559cf6e5111c9b9159810d0e4538e7cdc82/oidc.go#L43-L53 + c.OIDCContext = oidc.ClientContext(context.Background(), &http.Client{}) + log = internallog.NewDefaultLogger(c.LogLevel, c.LogFormat) return &c, err } @@ -247,7 +252,6 @@ func (c *Config) Validate() { func (c *Config) SetOidcProvider() { // Fetch OIDC Provider configuration - c.OIDCContext = context.Background() provider, err := oidc.NewProvider(c.OIDCContext, c.ProviderUri) if err != nil { log.Fatalf("failed to get provider configuration for %s: %v (hint: make sure %s is accessible from the cluster)", c.ProviderUri, err, c.ProviderUri)