Skip to content

Commit ef94864

Browse files
authored
Merge branch 'main' into aipolicy
2 parents 1a2c01a + ed587ca commit ef94864

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

modules/setting/admin.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package setting
55

66
import (
77
"code.gitea.io/gitea/modules/container"
8+
"code.gitea.io/gitea/modules/log"
89
)
910

1011
// Admin settings
@@ -15,12 +16,33 @@ var Admin struct {
1516
ExternalUserDisableFeatures container.Set[string]
1617
}
1718

19+
var validUserFeatures = container.SetOf(
20+
UserFeatureDeletion,
21+
UserFeatureManageSSHKeys,
22+
UserFeatureManageGPGKeys,
23+
UserFeatureManageMFA,
24+
UserFeatureManageCredentials,
25+
UserFeatureChangeUsername,
26+
UserFeatureChangeFullName,
27+
)
28+
1829
func loadAdminFrom(rootCfg ConfigProvider) {
1930
sec := rootCfg.Section("admin")
2031
Admin.DisableRegularOrgCreation = sec.Key("DISABLE_REGULAR_ORG_CREATION").MustBool(false)
2132
Admin.DefaultEmailNotification = sec.Key("DEFAULT_EMAIL_NOTIFICATIONS").MustString("enabled")
2233
Admin.UserDisabledFeatures = container.SetOf(sec.Key("USER_DISABLED_FEATURES").Strings(",")...)
2334
Admin.ExternalUserDisableFeatures = container.SetOf(sec.Key("EXTERNAL_USER_DISABLE_FEATURES").Strings(",")...).Union(Admin.UserDisabledFeatures)
35+
36+
for feature := range Admin.UserDisabledFeatures {
37+
if !validUserFeatures.Contains(feature) {
38+
log.Warn("USER_DISABLED_FEATURES contains unknown feature %q", feature)
39+
}
40+
}
41+
for feature := range Admin.ExternalUserDisableFeatures {
42+
if !validUserFeatures.Contains(feature) && !Admin.UserDisabledFeatures.Contains(feature) {
43+
log.Warn("EXTERNAL_USER_DISABLE_FEATURES contains unknown feature %q", feature)
44+
}
45+
}
2446
}
2547

2648
const (

0 commit comments

Comments
 (0)