Configure password complexity rules
I am trying to configure the password complexity rules of Identity, following the ABP docs:
appsettings.json
{
"Settings": {
"Abp.Identity.Password.RequireUppercase": "False"
}
}
However, when setting a password I still get the validation error "Passwords must have at least one uppercase ('A'-'Z')."
Try using cli to create a new project and use a new database. Maybe your database has related settings.
All right. But regardless of that then, this is a bug, right?
Changing the setting in the database works. I used the below snippet to update the setting:
GlobalSettingManagementProvider settingManagementProvider = context.ServiceProvider.GetRequiredService<GlobalSettingManagementProvider>();
SettingDefinitionManager settingDefinitionManager = context.ServiceProvider.GetRequiredService<SettingDefinitionManager>();
settingManagementProvider.SetAsync(
settingDefinitionManager.Get(IdentitySettingNames.Password.RequireUppercase),
false.ToString(),
GlobalSettingValueProvider.ProviderName
);
However, this was done in my HttpApiHostModule.OnApplicationInitialization method, which I can assume is definitely not a good place for changing global settings. I was not able to get an instance of GlobalSettingManagementProvider or SettingDefinitionManager in ConfigureServices or PreConfigureServices.
Could you please advise where the correct place would be to configure global settings? Perhaps I could just seed it in my project's DataSeederContributor?
This is not a bug, SettingValueProvider has priority, from bottom to top (user->tenant->global->configuration->defaultvalue).
https://github.com/abpframework/abp/blob/913d46b78bfc536380e1c1d03c5718ec62a5c286/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/AbpSettingsModule.cs#L25-L31
If you don't use user, tenant, global provider, appsettings.json configuration will take effect.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.