abp icon indicating copy to clipboard operation
abp copied to clipboard

Configure password complexity rules

Open duard-sf opened this issue 6 years ago • 5 comments

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')."

duard-sf avatar Feb 04 '20 12:02 duard-sf

Try using cli to create a new project and use a new database. Maybe your database has related settings.

maliming avatar Feb 05 '20 02:02 maliming

All right. But regardless of that then, this is a bug, right?

duard-sf avatar Feb 05 '20 04:02 duard-sf

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?

duard-sf avatar Feb 05 '20 04:02 duard-sf

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.

maliming avatar Feb 05 '20 05:02 maliming

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.

stale[bot] avatar Jul 29 '20 11:07 stale[bot]