fix(auth): remove auto-enable token auth logic

Signed-off-by: Noste <83548733+Noooste@users.noreply.github.com>
This commit is contained in:
Noste
2026-05-23 12:46:38 +02:00
parent dc9ea5716a
commit 1b645b0c2c
4 changed files with 1 additions and 53 deletions
-9
View File
@@ -328,15 +328,6 @@ func (c *Config) Validate() error {
return nil
}
// ResolveTokenAuth auto-enables token auth when no other auth method is
// configured, unless it was explicitly set. This ensures the app never
// starts without a login wall.
func (c *Config) ResolveTokenAuth() {
if !c.Auth.Admin.Enabled && !c.Auth.OIDC.Enabled && !c.Auth.Token.Enabled {
c.Auth.Token.Enabled = true
}
}
// GetAddress returns the full server address (host:port)
func (c *Config) GetAddress() string {
return fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
-40
View File
@@ -485,46 +485,6 @@ func TestLoad_EnvOverridesToml(t *testing.T) {
}
}
func TestValidate_TokenAuthAutoEnabled(t *testing.T) {
cfg := validBaseConfig()
cfg.ResolveTokenAuth()
if !cfg.Auth.Token.Enabled {
t.Error("expected token auth to be auto-enabled when no other auth is configured")
}
}
func TestValidate_TokenAuthNotAutoEnabledWhenAdminEnabled(t *testing.T) {
cfg := validBaseConfig()
cfg.Auth.Admin.Enabled = true
cfg.Auth.Admin.Username = "u"
cfg.Auth.Admin.Password = "p"
cfg.ResolveTokenAuth()
if cfg.Auth.Token.Enabled {
t.Error("expected token auth to stay disabled when admin auth is configured")
}
}
func TestValidate_TokenAuthNotAutoEnabledWhenOIDCEnabled(t *testing.T) {
cfg := validBaseConfig()
applyValidOIDC(&cfg)
cfg.ResolveTokenAuth()
if cfg.Auth.Token.Enabled {
t.Error("expected token auth to stay disabled when OIDC is configured")
}
}
func TestValidate_TokenAuthExplicitlyEnabled(t *testing.T) {
cfg := validBaseConfig()
cfg.Auth.Admin.Enabled = true
cfg.Auth.Admin.Username = "u"
cfg.Auth.Admin.Password = "p"
cfg.Auth.Token.Enabled = true
cfg.ResolveTokenAuth()
if !cfg.Auth.Token.Enabled {
t.Error("expected token auth to stay enabled when explicitly set")
}
}
func TestEffectiveAdminRoles(t *testing.T) {
tests := []struct {
name string