NetEscapades.AspNetCore.Identity.Validators
NetEscapades.AspNetCore.Identity.Validators copied to clipboard
A collection of ASP.NET Core Identity IPasswordValidators
NetEscapades.AspNetCore.Identity.Validators
A collection of ASP.NET Core Identity IPasswordValidators
for use with Microsoft.AspNetCore.Identity.EntityFrameworkCore.
Usage
Includes the following validators:
-
EmailAsPasswordValidator
- Verify the user has not used their email as their password -
UsernameAsPasswordValidator
- Verify the user has not used their email as their password -
InvalidPhraseValidator
- Ensure the user hasn't used specific phrases, such as the url or domain of your website
You can add the validators to your project using the AddPasswordValidator<TValidator>
method exposed by IdentityBuilder
. Alternatively, use the extension methods on IdentityBuilder
included in the package:
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders()
.AddEmailAsPasswordValidator<ApplicationUser>() // Add the email as password validator
.AddUsernameAsPasswordValidator<ApplicationUser>() // Add the username as password validator
.AddInvalidPhraseValidator<ApplicationUser>(new []{"MyDomainName.com"}); // Add the invalid phrase validator
NOTE This package currently support ASP.NET Core Identity 2.0 (.NET Standard 2.0) and .NET Core 3.0
Installing
Install using the NetEscapades.AspNetCore.Identity.Validators NuGet package:
PM> Install-Package NetEscapades.AspNetCore.Identity.Validators
or
dotnet add package NetEscapades.AspNetCore.Identity.Validators