diff --git a/lib/service/service.go b/lib/service/service.go index d38d5d18cc681..3de8967dd71f3 100644 --- a/lib/service/service.go +++ b/lib/service/service.go @@ -6031,8 +6031,8 @@ func warnOnErr(ctx context.Context, err error, log *slog.Logger) { // initAuthStorage initializes the storage backend for the auth service. func (process *TeleportProcess) initAuthStorage() (backend.Backend, error) { ctx := context.TODO() - process.logger.DebugContext(process.ExitContext(), "Initializing auth backend.", "backend", process.Config.Auth.StorageConfig.Type) bc := process.Config.Auth.StorageConfig + process.logger.DebugContext(process.ExitContext(), "Initializing auth backend.", "type", bc.Type) bk, err := backend.New(ctx, bc.Type, bc.Params) if err != nil { return nil, trace.Wrap(err) diff --git a/lib/service/servicecfg/config.go b/lib/service/servicecfg/config.go index 43ce5ce202526..bdc36f0416523 100644 --- a/lib/service/servicecfg/config.go +++ b/lib/service/servicecfg/config.go @@ -558,7 +558,7 @@ func ApplyDefaults(cfg *Config) { cfg.Auth.Enabled = true cfg.Auth.ListenAddr = *defaults.AuthListenAddr() cfg.Auth.StorageConfig.Type = lite.GetName() - cfg.Auth.StorageConfig.Params = backend.Params{defaults.BackendPath: filepath.Join(cfg.DataDir, defaults.BackendDir)} + cfg.Auth.StorageConfig.Params = make(backend.Params) cfg.Auth.StaticTokens = types.DefaultStaticTokens() cfg.Auth.AuditConfig = types.DefaultClusterAuditConfig() cfg.Auth.NetworkingConfig = types.DefaultClusterNetworkingConfig() @@ -661,6 +661,15 @@ func ValidateConfig(cfg *Config) error { return trace.BadParameter("config: please supply data directory") } + if cfg.Auth.Enabled { + if cfg.Auth.StorageConfig.Params.GetString(defaults.BackendPath) == "" { + if cfg.Auth.StorageConfig.Params == nil { + cfg.Auth.StorageConfig.Params = make(backend.Params) + } + cfg.Auth.StorageConfig.Params[defaults.BackendPath] = filepath.Join(cfg.DataDir, defaults.BackendDir) + } + } + for i := range cfg.Auth.Authorities { if err := services.ValidateCertAuthority(cfg.Auth.Authorities[i]); err != nil { return trace.Wrap(err) diff --git a/lib/service/servicecfg/config_test.go b/lib/service/servicecfg/config_test.go index 874924ab80a2e..d23362be2d60b 100644 --- a/lib/service/servicecfg/config_test.go +++ b/lib/service/servicecfg/config_test.go @@ -22,7 +22,6 @@ import ( "fmt" "io" "log/slog" - "path/filepath" "regexp" "strings" "testing" @@ -90,7 +89,7 @@ func TestDefaultConfig(t *testing.T) { require.Equal(t, int64(defaults.LimiterMaxConnections), auth.Limiter.MaxConnections) require.Equal(t, defaults.LimiterMaxConcurrentUsers, auth.Limiter.MaxNumberOfUsers) require.Equal(t, lite.GetName(), config.Auth.StorageConfig.Type) - require.Equal(t, filepath.Join(config.DataDir, defaults.BackendDir), auth.StorageConfig.Params[defaults.BackendPath]) + require.Empty(t, auth.StorageConfig.Params[defaults.BackendPath]) // SSH section ssh := config.SSH