Different security settings per user type / user group #21631
Replies: 2 comments 2 replies
-
|
I just want to note that password complexity has proven to be mostly useless, long passwords are the hardest ones to crack. Personally, I think we should hold anybody who can log in to the backoffice to the same standard of having a long password. Agreed on improving MFA management. Additionally, I would love to see passkeys being discussed as a complete replacement for logging in with passwords. I know they're not quite mainstream yet and there's various challenges with password managers, so it could be opt-in with a good fallback for now. |
Beta Was this translation helpful? Give feedback.
-
|
We discussed and investigated this a little this morning, and at least the password complexity requirement can be handled already by registering a custom using Microsoft.AspNetCore.Identity;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Security;
namespace Umbraco.Cms.Web.UI.Custom;
public class GroupBasedPasswordValidator : IPasswordValidator<BackOfficeIdentityUser>
{
public Task<IdentityResult> ValidateAsync(
UserManager<BackOfficeIdentityUser> manager,
BackOfficeIdentityUser? user,
string? password)
{
if (user == null || string.IsNullOrEmpty(password))
{
return Task.FromResult(IdentityResult.Success);
}
var errors = new List<IdentityError>();
var isAdmin = user.Roles.Any(r =>
r.RoleId.Equals("admin", StringComparison.OrdinalIgnoreCase));
if (isAdmin)
{
// Administrators: 20+ characters, must have digits and symbols.
if (password.Length < 20)
{
errors.Add(new IdentityError
{
Code = "AdminPasswordTooShort",
Description = "Administrator passwords must be at least 20 characters."
});
}
if (!password.Any(char.IsDigit))
{
errors.Add(new IdentityError
{
Code = "AdminPasswordRequiresDigit",
Description = "Administrator passwords must contain at least one digit."
});
}
if (!password.Any(c => !char.IsLetterOrDigit(c)))
{
errors.Add(new IdentityError
{
Code = "AdminPasswordRequiresSymbol",
Description = "Administrator passwords must contain at least one symbol."
});
}
}
else
{
// Editors/other users: standard 10 character minimum.
// (Or could fallback to defaults here).
if (password.Length < 10)
{
errors.Add(new IdentityError
{
Code = "PasswordTooShort",
Description = "Password must be at least 10 characters."
});
}
}
return Task.FromResult(errors.Count > 0
? IdentityResult.Failed(errors.ToArray())
: IdentityResult.Success);
}
}
public class PasswordValidationComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Services.AddScoped<IPasswordValidator<BackOfficeIdentityUser>, GroupBasedPasswordValidator>();
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem statement
Umbraco currently provides very flexible password complexity configuration, but it follows a one-size-fits-all approach.
As a result:
This makes it difficult to apply appropriate security controls based on risk level and role, especially in environments with:
Proposed idea
Allow different security settings for different types of users, ideally based on user groups.
A group-based approach would likely be the most flexible and align well with existing Umbraco concepts.
Examples of settings that could be group-specific:
Open discussion
This discussion can be used to:
Note
This ticket was discussed within the Umbraco Security & Privacy Advisors group; I’m formalising it here to gather broader feedback.
Beta Was this translation helpful? Give feedback.
All reactions