Skip to content

Commit acdffa6

Browse files
committed
fix(authentication): feature should be disabled by default
Contrary to what the PR for the feature mentioned, the setting was enabled by default, instead of disabled. Follow up to #8854
1 parent f2de2dc commit acdffa6

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

backend/helpers/oidchelper/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ func (c *Config) ProviderNames() []string {
8888
}
8989

9090
// LoadConfig reads auth env vars via Viper and validates required fields.
91-
// AUTH_ENABLED defaults to true unless it is explicitly set to false.
91+
// AUTH_ENABLED defaults to false unless it is explicitly set to true.
9292
func LoadConfig(basicRes context.BasicRes) (*Config, error) {
9393
cfg := basicRes.GetConfigReader()
9494

95-
authEnabled := true
95+
authEnabled := false
9696
if cfg.IsSet("AUTH_ENABLED") {
9797
authEnabled = cfg.GetBool("AUTH_ENABLED")
9898
}

backend/helpers/oidchelper/config_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ func (b basicResStub) ReplaceLogger(log.Logger) corectx.BasicRes {
105105
}
106106
func (b basicResStub) GetDal() dal.Dal { return nil }
107107

108-
func TestLoadConfigDefaultsAuthEnabled(t *testing.T) {
108+
func TestLoadConfigDefaultsAuthDisabled(t *testing.T) {
109109
v := viper.New()
110110

111111
cfg, err := LoadConfig(basicResStub{cfg: v})
112112
if err != nil {
113113
t.Fatalf("LoadConfig returned error: %v", err)
114114
}
115-
if !cfg.AuthEnabled {
116-
t.Fatal("AuthEnabled should default to true when AUTH_ENABLED is unset")
115+
if cfg.AuthEnabled {
116+
t.Fatal("AuthEnabled should default to false when AUTH_ENABLED is unset")
117117
}
118118
if cfg.OIDCEnabled {
119119
t.Fatal("OIDCEnabled should default to false")
@@ -125,6 +125,7 @@ func TestLoadConfigDefaultsAuthEnabled(t *testing.T) {
125125

126126
func TestLoadConfigRequiresSessionSecretForOIDC(t *testing.T) {
127127
v := viper.New()
128+
v.Set("AUTH_ENABLED", true)
128129
v.Set("OIDC_ENABLED", true)
129130

130131
if _, err := LoadConfig(basicResStub{cfg: v}); err == nil {

env.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ ENABLE_SUBTASKS_BY_DEFAULT="jira:collectIssueChangelogs:true,jira:extractIssueCh
9797
##########################
9898
# OIDC / Authentication
9999
##########################
100-
# Master switch. Auth is enabled by default; set false only for isolated local
101-
# development. When enabled without OIDC, DevLake accepts API keys for /rest/*
102-
# and can trust X-Forwarded-User from an upstream proxy.
103-
AUTH_ENABLED=true
100+
# Master switch. Auth is disabled by default; set true to require
101+
# authentication. When enabled without OIDC, DevLake accepts API keys for
102+
# /rest/* and can trust X-Forwarded-User from an upstream proxy.
103+
AUTH_ENABLED=false
104104

105105
# OIDC user login. Requires AUTH_ENABLED=true.
106106
OIDC_ENABLED=false

0 commit comments

Comments
 (0)