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,9 +52,13 @@ func Initialize( | ||||||
| 	// Switch to admin user context
 | 	// Switch to admin user context
 | ||||||
| 	startupContext = domain.SetUserInfo(startupContext, domain.SystemAdminContextUserInfo()) | 	startupContext = domain.SetUserInfo(startupContext, domain.SystemAdminContextUserInfo()) | ||||||
| 
 | 
 | ||||||
|  | 	if !cfg.Core.AdminUserDisabled { | ||||||
| 		if err := a.createDefaultUser(startupContext); err != nil { | 		if err := a.createDefaultUser(startupContext); err != nil { | ||||||
| 			return fmt.Errorf("failed to create default user: %w", err) | 			return fmt.Errorf("failed to create default user: %w", err) | ||||||
| 		} | 		} | ||||||
|  | 	} else { | ||||||
|  | 		slog.Info("Local Admin user disabled!") | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	if err := a.importNewInterfaces(startupContext); err != nil { | 	if err := a.importNewInterfaces(startupContext); err != nil { | ||||||
| 		return fmt.Errorf("failed to import new interfaces: %w", err) | 		return fmt.Errorf("failed to import new interfaces: %w", err) | ||||||
|  |  | ||||||
|  | @ -14,6 +14,7 @@ import ( | ||||||
| type Config struct { | type Config struct { | ||||||
| 	Core struct { | 	Core struct { | ||||||
| 		// AdminUser defines the default administrator account that will be created
 | 		// AdminUser defines the default administrator account that will be created
 | ||||||
|  | 		AdminUserDisabled bool   `yaml:"disable_admin_user"` | ||||||
| 		AdminUser         string `yaml:"admin_user"` | 		AdminUser         string `yaml:"admin_user"` | ||||||
| 		AdminPassword     string `yaml:"admin_password"` | 		AdminPassword     string `yaml:"admin_password"` | ||||||
| 		AdminApiToken     string `yaml:"admin_api_token"` // if set, the API access is enabled automatically
 | 		AdminApiToken     string `yaml:"admin_api_token"` // if set, the API access is enabled automatically
 | ||||||
|  | @ -113,6 +114,7 @@ func (c *Config) LogStartupValues() { | ||||||
| func defaultConfig() *Config { | func defaultConfig() *Config { | ||||||
| 	cfg := &Config{} | 	cfg := &Config{} | ||||||
| 
 | 
 | ||||||
|  | 	cfg.Core.AdminUserDisabled = false | ||||||
| 	cfg.Core.AdminUser = "admin@wgportal.local" | 	cfg.Core.AdminUser = "admin@wgportal.local" | ||||||
| 	cfg.Core.AdminPassword = "wgportal-default" | 	cfg.Core.AdminPassword = "wgportal-default" | ||||||
| 	cfg.Core.AdminApiToken = "" // by default, the API access is disabled
 | 	cfg.Core.AdminApiToken = "" // by default, the API access is disabled
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue