diff --git a/lib/service/service.go b/lib/service/service.go index cc3e455855635..7f0b89e1bc3b1 100644 --- a/lib/service/service.go +++ b/lib/service/service.go @@ -5944,8 +5944,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 f42c8824e6f5d..70e6e40695cb0 100644 --- a/lib/service/servicecfg/config.go +++ b/lib/service/servicecfg/config.go @@ -550,7 +550,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() @@ -652,6 +652,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 6c47d7d7daf58..a4c8949fdeb8f 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" @@ -89,7 +88,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