Auth: Separate anonymous settings to its own struct (#97791)
separate anonymous settings to its own struct
This commit is contained in:
+2
-11
@@ -302,11 +302,7 @@ type Cfg struct {
|
||||
// Deprecated: use featuremgmt.FeatureFlags
|
||||
IsFeatureToggleEnabled func(key string) bool // filled in dynamically
|
||||
|
||||
AnonymousEnabled bool
|
||||
AnonymousOrgName string
|
||||
AnonymousOrgRole string
|
||||
AnonymousHideVersion bool
|
||||
AnonymousDeviceLimit int64
|
||||
Anonymous AnonymousSettings
|
||||
|
||||
DateFormats DateFormats
|
||||
|
||||
@@ -1654,12 +1650,7 @@ func readAuthSettings(iniFile *ini.File, cfg *Cfg) (err error) {
|
||||
}
|
||||
|
||||
// anonymous access
|
||||
anonSection := iniFile.Section("auth.anonymous")
|
||||
cfg.AnonymousEnabled = anonSection.Key("enabled").MustBool(false)
|
||||
cfg.AnonymousOrgName = valueAsString(anonSection, "org_name", "")
|
||||
cfg.AnonymousOrgRole = valueAsString(anonSection, "org_role", "")
|
||||
cfg.AnonymousHideVersion = anonSection.Key("hide_version").MustBool(false)
|
||||
cfg.AnonymousDeviceLimit = anonSection.Key("device_limit").MustInt64(0)
|
||||
cfg.readAnonymousSettings()
|
||||
|
||||
// basic auth
|
||||
authBasic := iniFile.Section("auth.basic")
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package setting
|
||||
|
||||
type AnonymousSettings struct {
|
||||
Enabled bool
|
||||
OrgName string
|
||||
OrgRole string
|
||||
HideVersion bool
|
||||
DeviceLimit int64
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readAnonymousSettings() {
|
||||
anonSection := cfg.Raw.Section("auth.anonymous")
|
||||
|
||||
anonSettings := AnonymousSettings{}
|
||||
anonSettings.Enabled = anonSection.Key("enabled").MustBool(false)
|
||||
anonSettings.OrgName = valueAsString(anonSection, "org_name", "")
|
||||
anonSettings.OrgRole = valueAsString(anonSection, "org_role", "")
|
||||
anonSettings.HideVersion = anonSection.Key("hide_version").MustBool(false)
|
||||
anonSettings.DeviceLimit = anonSection.Key("device_limit").MustInt64(0)
|
||||
cfg.Anonymous = anonSettings
|
||||
}
|
||||
Reference in New Issue
Block a user