mirror of https://github.com/h44z/wg-portal.git
allow disabling local admin user (#515)
This commit is contained in:
parent
d311313cb4
commit
b61d84ec4f
|
|
@ -52,8 +52,12 @@ func Initialize(
|
|||
// Switch to admin user context
|
||||
startupContext = domain.SetUserInfo(startupContext, domain.SystemAdminContextUserInfo())
|
||||
|
||||
if err := a.createDefaultUser(startupContext); err != nil {
|
||||
return fmt.Errorf("failed to create default user: %w", err)
|
||||
if !cfg.Core.AdminUserDisabled {
|
||||
if err := a.createDefaultUser(startupContext); err != nil {
|
||||
return fmt.Errorf("failed to create default user: %w", err)
|
||||
}
|
||||
} else {
|
||||
slog.Info("Local Admin user disabled!")
|
||||
}
|
||||
|
||||
if err := a.importNewInterfaces(startupContext); err != nil {
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@ import (
|
|||
type Config struct {
|
||||
Core struct {
|
||||
// AdminUser defines the default administrator account that will be created
|
||||
AdminUser string `yaml:"admin_user"`
|
||||
AdminPassword string `yaml:"admin_password"`
|
||||
AdminApiToken string `yaml:"admin_api_token"` // if set, the API access is enabled automatically
|
||||
AdminUserDisabled bool `yaml:"disable_admin_user"`
|
||||
AdminUser string `yaml:"admin_user"`
|
||||
AdminPassword string `yaml:"admin_password"`
|
||||
AdminApiToken string `yaml:"admin_api_token"` // if set, the API access is enabled automatically
|
||||
|
||||
EditableKeys bool `yaml:"editable_keys"`
|
||||
CreateDefaultPeer bool `yaml:"create_default_peer"`
|
||||
|
|
@ -113,6 +114,7 @@ func (c *Config) LogStartupValues() {
|
|||
func defaultConfig() *Config {
|
||||
cfg := &Config{}
|
||||
|
||||
cfg.Core.AdminUserDisabled = false
|
||||
cfg.Core.AdminUser = "admin@wgportal.local"
|
||||
cfg.Core.AdminPassword = "wgportal-default"
|
||||
cfg.Core.AdminApiToken = "" // by default, the API access is disabled
|
||||
|
|
|
|||
Loading…
Reference in New Issue