diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go index 1c832be..6aa2b9b 100644 --- a/cmd/proxy/main.go +++ b/cmd/proxy/main.go @@ -16,6 +16,7 @@ var ( serverPort string defaultAudience string tokenSourceCacheDuration string + debugGoproxy bool ) func main() { @@ -36,6 +37,7 @@ func main() { cmd.Flags().StringVar(&serverHost, "host", "0.0.0.0", "server host") cmd.Flags().StringVar(&serverPort, "port", "8100", "server port") cmd.Flags().StringVar(&tokenSourceCacheDuration, "token-source-cache-duration", "30m", "token source cache duration") + cmd.Flags().BoolVar(&debugGoproxy, "debug-goproxy", false, "verbose logging about elazarl/goproxy") if err := cmd.Execute(); err != nil { slog.Error("error occurred", "error", err) @@ -49,6 +51,7 @@ func run(cmd *cobra.Command, args []string) error { ServerPort: serverPort, DefaultAudience: defaultAudience, TokenSourceCacheDuration: tokenSourceCacheDuration, + DebugGoproxy: debugGoproxy, } r, err := runner.New(cfg) diff --git a/pkg/runner/proc.go b/pkg/runner/proc.go index cce0a21..95fa32b 100644 --- a/pkg/runner/proc.go +++ b/pkg/runner/proc.go @@ -44,6 +44,7 @@ func (p *proc) Start(ctx context.Context) (_ <-chan error, err error) { p.idtoken, err = idtoken.New( idtoken.WithDefaultAudience(p.DefaultAudience), idtoken.WithTokenSourceCacheDuration(p.TokenSourceCacheDuration), + idtoken.WithDebugGoproxy(p.DebugGoproxy), ) if err != nil { return nil, err diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index e80d35e..55c3286 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -14,6 +14,7 @@ type Config struct { ServerPort string DefaultAudience string TokenSourceCacheDuration string + DebugGoproxy bool } // Runner represents main routine interface diff --git a/pkg/service/google/idtoken/option.go b/pkg/service/google/idtoken/option.go index 9996b7f..6f7a539 100644 --- a/pkg/service/google/idtoken/option.go +++ b/pkg/service/google/idtoken/option.go @@ -34,3 +34,15 @@ func (o tsCacheDurationOption) Apply(s *server) error { func WithTokenSourceCacheDuration(dur string) tsCacheDurationOption { return tsCacheDurationOption(dur) } + +type debugGoproxyOption bool + +func (o debugGoproxyOption) Apply(s *server) error { + s.proxy.Verbose = bool(o) + + return nil +} + +func WithDebugGoproxy(b bool) debugGoproxyOption { + return debugGoproxyOption(b) +}