From f79912c1a18f86bac072776709276cd53c3c6754 Mon Sep 17 00:00:00 2001 From: jay brown Date: Tue, 18 Mar 2025 16:46:11 -0700 Subject: [PATCH] cleanup temp --- cmd/queryService/main.go | 4 ++-- internal/server/service/listener.go | 14 ++++++++++++++ internal/serviceconfig/common.go | 3 ++- internal/serviceconfig/rbac/config.go | 8 ++++---- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/cmd/queryService/main.go b/cmd/queryService/main.go index 7ac9a04b..597a5e8b 100644 --- a/cmd/queryService/main.go +++ b/cmd/queryService/main.go @@ -96,8 +96,8 @@ func main() { } // Both of these operations (InitializeConfig and InitializeAuthProvider) - // would be better off in the service.new but there are temporal dependencies - // that make this not possible right now without more refactoring. + // would be better off in the service.new but there are code dependencies + // that make this not possible right now without significant refactoring. // This must be done before the rbac.InitializeAuthProvider errInitializingConfig := serviceconfig.InitializeConfig(cfg) diff --git a/internal/server/service/listener.go b/internal/server/service/listener.go index 68a2f820..fea9d31a 100644 --- a/internal/server/service/listener.go +++ b/internal/server/service/listener.go @@ -88,6 +88,20 @@ func getSlogCustomEchoMiddleware(logger *slog.Logger) echo.MiddlewareFunc { } func New(ctx context.Context, cfg Config) (*Server, error) { + // Put this in when refactoring is done and remove from main.go + + //// This must be done before the rbac.InitializeAuthProvider then remove from main.go for service. + //errInitializingConfig := serviceconfig.InitializeConfig(cfg) + //if errInitializingConfig != nil { + // return nil, errInitializingConfig + //} + // + //// Initialize the rbac config here since only the API service needs it + //errorGettingAuthProvider := rbac.InitializeAuthProvider(cfg.GetAuthConfig()) + //if errorGettingAuthProvider != nil { + // return nil, errorGettingAuthProvider + //} + cleanup, err := server.New(ctx, cfg) if err != nil { return nil, err diff --git a/internal/serviceconfig/common.go b/internal/serviceconfig/common.go index b0a112d9..893f0dd5 100644 --- a/internal/serviceconfig/common.go +++ b/internal/serviceconfig/common.go @@ -29,7 +29,7 @@ import ( // that can be embedded in service-specific configs. type BaseConfig struct { // Always place non struct fields at the top of the struct - // this is a requirement for the PrintConfig function. + // this is a requirement for the PrintAuthConfig function. // miscellaneous fields uncategorized // PWD will replace the BASE_PATH env var @@ -56,6 +56,7 @@ type ConfigProvider interface { logger.ConfigProvider aws.ConfigProvider queue.ConfigProvider + rbac.ConfigProvider GetBasePath() string SetBasePath(string) SetDBConfig(*database.DBConfig) diff --git a/internal/serviceconfig/rbac/config.go b/internal/serviceconfig/rbac/config.go index bcc35090..4f83c75f 100644 --- a/internal/serviceconfig/rbac/config.go +++ b/internal/serviceconfig/rbac/config.go @@ -26,7 +26,7 @@ type AuthConfig struct { type ConfigProvider interface { //Initialize() error GetKeyProvider() rbac.KeyProvider - PrintConfig() + PrintAuthConfig() } // GetKeyProvider returns the configured KeyProvider @@ -58,13 +58,13 @@ func (r *AuthConfig) InitializeAuthProvider() error { default: return fmt.Errorf("unknown RBAC provider type: %s", r.AuthType) } - r.PrintConfig() + r.PrintAuthConfig() return nil } -// PrintConfig logs the current configuration, masking sensitive values -func (r *AuthConfig) PrintConfig() { +// PrintAuthConfig logs the current configuration, masking sensitive values +func (r *AuthConfig) PrintAuthConfig() { slog.Info("RBAC AuthConfig:", "provider_type", r.AuthType, "region", r.CognitoRegion,