Skip to content

deremakif/NetEscapades.AspNetCore.Identity.Validators

 
 

Repository files navigation

NetEscapades.AspNetCore.Identity.Validators

Build status

NuGet MyGet CI

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 is currently for ASP.NET Core Identity 2.0-preview-2, so requires .NET Core 2.0-preview2 be installed.

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

Additional Resources

About

A collection of ASP.NET Core Identity IPasswordValidators

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 80.1%
  • PowerShell 13.2%
  • Shell 6.7%