feat(auth): require changing default admin password (#778)

This commit is contained in:
h44z
2026-11-09 19:57:23 +01:00
committed by GitHub
parent 137286d46b
commit 276f120b60
30 changed files with 641 additions and 90 deletions
+28
View File
@@ -281,6 +281,34 @@ func (m Manager) DeactivateApi(ctx context.Context, id domain.UserIdentifier) (*
return user, nil
}
// IsDefaultPasswordInUse checks if the default admin user or any admin user is still using the default password.
func (m Manager) IsDefaultPasswordInUse(ctx context.Context) bool {
adminCtx := domain.SetUserInfo(ctx, domain.SystemAdminContextUserInfo())
adminUserId := domain.UserIdentifier(m.cfg.Core.AdminUser)
if adminUserId == "" {
adminUserId = config.DefaultAdminUser
}
adminUser, err := m.users.GetUser(adminCtx, adminUserId)
if err == nil && adminUser != nil {
if adminUser.CheckPassword(config.DefaultAdminPassword) == nil {
return true
}
}
allUsers, err := m.users.GetAllUsers(adminCtx)
if err == nil {
for _, u := range allUsers {
if u.IsAdmin && u.CheckPassword(config.DefaultAdminPassword) == nil {
return true
}
}
}
return false
}
func (m Manager) validateModifications(ctx context.Context, old, new *domain.User) error {
currentUser := domain.GetUserInfo(ctx)