diff --git a/internal/bootstrap/app_bootstrap.go b/internal/bootstrap/app_bootstrap.go index b9c3830..5f9b906 100644 --- a/internal/bootstrap/app_bootstrap.go +++ b/internal/bootstrap/app_bootstrap.go @@ -150,18 +150,6 @@ func (app *BootstrapApp) Setup() error { configuredProviders := make([]controller.Provider, 0) for id, provider := range oauthProviders { - if id == "" { - continue - } - - if provider.Name == "" { - if name, ok := config.OverrideProviders[id]; ok { - provider.Name = name - } else { - provider.Name = utils.Capitalize(id) - } - } - configuredProviders = append(configuredProviders, controller.Provider{ Name: provider.Name, ID: id, diff --git a/internal/service/oauth_broker_service.go b/internal/service/oauth_broker_service.go index 178f9af..1038184 100644 --- a/internal/service/oauth_broker_service.go +++ b/internal/service/oauth_broker_service.go @@ -50,7 +50,7 @@ func (broker *OAuthBrokerService) Init() error { log.Error().Err(err).Msgf("Failed to initialize OAuth service: %T", name) return err } - log.Info().Str("service", service.GetName()).Msg("Initialized OAuth service") + log.Info().Str("service", name).Msg("Initialized OAuth service") } return nil diff --git a/internal/utils/app_utils.go b/internal/utils/app_utils.go index 42649cd..de0cff6 100644 --- a/internal/utils/app_utils.go +++ b/internal/utils/app_utils.go @@ -184,7 +184,6 @@ func GetOAuthProvidersConfig(env []string, args []string, appUrl string) (map[st } // If we have google/github providers and no redirect URL then set a default - for id := range config.OverrideProviders { if provider, exists := providers[id]; exists { if provider.RedirectURL == "" { @@ -194,6 +193,18 @@ func GetOAuthProvidersConfig(env []string, args []string, appUrl string) (map[st } } + // Set names + for id, provider := range providers { + if provider.Name == "" { + if name, ok := config.OverrideProviders[id]; ok { + provider.Name = name + } else { + provider.Name = Capitalize(id) + } + } + providers[id] = provider + } + // Return combined providers return providers, nil } diff --git a/internal/utils/app_utils_test.go b/internal/utils/app_utils_test.go index a7f09fe..d8abcab 100644 --- a/internal/utils/app_utils_test.go +++ b/internal/utils/app_utils_test.go @@ -210,10 +210,12 @@ func TestGetOAuthProvidersConfig(t *testing.T) { "client1": { ClientID: "client1-id", ClientSecret: "client1-secret", + Name: "Client1", }, "client2": { ClientID: "client2-id", ClientSecret: "client2-secret", + Name: "Client2", }, } @@ -247,6 +249,7 @@ func TestGetOAuthProvidersConfig(t *testing.T) { "client1": { ClientID: "client1-id", ClientSecret: "file content", + Name: "Client1", }, } @@ -262,6 +265,7 @@ func TestGetOAuthProvidersConfig(t *testing.T) { ClientID: "google-id", ClientSecret: "google-secret", RedirectURL: "http://app.url/api/oauth/callback/google", + Name: "Google", }, }