The default Identity provider provided in ASP.NET 5 has very strict password rules by default, requiring a lower case character, an upper case character, a non-alphanumeric character, and a number. I am looking for a way to change the password requirements for the provider.
Previously in ASP.NET 4, the provider could be configured via the Web.config XML file, as previously answered. However ASP.NET 5 uses the new code based configuration pattern and it is unclear how to configure the identity.
How can I change the password requirements for my application?
I actually ended up figuring this out, it turns out you need to supply AddDefaultIdentity with a suitable lambda expression that configures the IdentityOptions it provides. This is done inside the ConfigureServices method within the Startup class, like so:
Update 2:
The above was true in the beta1 versions of the framework, in the latest
rc1beta5 it has changed slightly to:If you have set up a new Web project with
Individual User Accounts
go to:There you can edit the following defaults:
in startup.cs:
What I wanted to do was to customize the password rule so that it should contain characters from at least 2 of the following groups: lower case, upper case, digits and special symbols.
This is not something that I could do by just changing PasswordValidator options:
So instead I created a custom validator by extending IIdentityValidator...
First, create a new file CustomPasswordValidator.cs in your Extensions folder:
Then go to IdentityConfig.cs, and initialize it in Create method: