From 2ef116fe1a08e76b7beb3529d1c62a438b11c2f4 Mon Sep 17 00:00:00 2001 From: jay brown Date: Fri, 18 Apr 2025 13:00:08 -0700 Subject: [PATCH] pr cleanup --- internal/serviceconfig/auth/config.go | 38 +++++++++++++++------------ internal/serviceconfig/common.go | 1 - 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/internal/serviceconfig/auth/config.go b/internal/serviceconfig/auth/config.go index d713b548..d31ddba0 100644 --- a/internal/serviceconfig/auth/config.go +++ b/internal/serviceconfig/auth/config.go @@ -144,27 +144,31 @@ func InitializeConfig(baseURL string, logger *slog.Logger) *CognitoConfig { } func (c *CognitoConfig) PrettyPrintDebugOnly() { - if os.Getenv("DEBUG") == "true" { - fmt.Printf("CognitoConfig (debug on):\n") - fmt.Printf(" AuthClientID: %s\n", c.AuthClientID) - fmt.Printf(" AuthClientSecret: %s\n", c.AuthClientSecret) - fmt.Printf(" AuthRedirectURI: %s\n", c.AuthRedirectURI) - fmt.Printf(" AuthTokenURL: %s\n", c.AuthTokenURL) - fmt.Printf(" AuthURL: %s\n", c.AuthURL) - fmt.Printf(" AuthJwksURL: %s\n", c.AuthJwksURL) - fmt.Printf(" AuthUserPoolID: %s\n", c.AuthUserPoolID) - fmt.Printf(" AuthRegion: %s\n", c.AuthRegion) - fmt.Printf(" AuthLoginPath: %s\n", c.AuthLoginPath) - fmt.Printf(" AuthCallbackPath: %s\n", c.AuthCallbackPath) - fmt.Printf(" AuthHomePath: %s\n", c.AuthHomePath) - fmt.Printf(" AuthLogoutPath: %s\n", c.AuthLogoutPath) - fmt.Printf(" DisableAuth: %s\n", c.DisableAuth) - fmt.Printf(" AuthDomain: %s\n", c.AuthDomain) + logger := c.AuthLogger + if logger != nil { + logger.Debug("CognitoConfig details", + "AuthClientID", c.AuthClientID, + "AuthClientSecret", c.AuthClientSecret, + "AuthRedirectURI", c.AuthRedirectURI, + "AuthTokenURL", c.AuthTokenURL, + "AuthURL", c.AuthURL, + "AuthJwksURL", c.AuthJwksURL, + "AuthUserPoolID", c.AuthUserPoolID, + "AuthRegion", c.AuthRegion, + "AuthLoginPath", c.AuthLoginPath, + "AuthCallbackPath", c.AuthCallbackPath, + "AuthHomePath", c.AuthHomePath, + "AuthLogoutPath", c.AuthLogoutPath, + "DisableAuth", c.DisableAuth, + "AuthDomain", c.AuthDomain) // pretty print the route permissions map for route, permissions := range c.AuthRoutePermissions { - fmt.Printf(" Route: %s, Permissions: %v\n", route, permissions) + logger.Debug("Route permission", + "route", route, + "permissions", permissions) } + } } diff --git a/internal/serviceconfig/common.go b/internal/serviceconfig/common.go index fbe41149..6eda5400 100644 --- a/internal/serviceconfig/common.go +++ b/internal/serviceconfig/common.go @@ -33,7 +33,6 @@ type BaseConfig struct { // this is a requirement for the PrintAuthConfig function. // These are the fields that are common to all services. - //Pwd string `env:"PWD,required,notEmpty"` Port int `env:"PORT" envDefault:"8080"` BaseURL string `env:"BASE_URL" envDefault:"http://localhost"` auth.CognitoConfig