Introduce IdentityCore.Adapter.AspNetMembership

karimfahmy

Karim Fahmy

Posted on January 11, 2023

Introduce IdentityCore.Adapter.AspNetMembership

IdentityCore.Adapter.AspNetMembership

Is a Adapter library that enables you to use Microsoft Identity with existing code base using AspNetMembership user management
to have several new features like Two-Factor Authentication, Account Lockout, Account Confirmation, Password Reset, Security Stamp (Sign-Out Everywhere) and external login with existing Facebook, Google, Twitter or Live login.

Before, these features had to be coded,

so now developers can focus more on main business while using tested and standardized method to manage users.

Required

.Net 6 Framework

Installation

Install by Nuget

  dotnet add package IdentityCore.Adapter.AspNetMembership
Enter fullscreen mode Exit fullscreen mode

Usage

if you are using the default schema of AspNetMemberShip without any customization

as well you can include identity options.

services.AddIdentityAdapter(SqlConnectionString);

//or

services.AddIdentityAdapter(SqlConnection, opts =>
            {
                opts.Password.RequiredLength = 8;
                opts.Password.RequireNonAlphanumeric = true;
                opts.Password.RequireLowercase = false;
                opts.Password.RequireUppercase = true;
                opts.Password.RequireDigit = true;
            }); 
Enter fullscreen mode Exit fullscreen mode

if you are using the customize schema of AspNetMemberShip create your own CustomUserStore.cs and CustomRoleStore.cs to adapted your customization

services.AddIdentityAdapter(SqlConnection, opts =>
            {
                opts.Password.RequiredLength = 8;
                opts.Password.RequireNonAlphanumeric = true;
                opts.Password.RequireLowercase = false;
                opts.Password.RequireUppercase = true;
                opts.Password.RequireDigit = true;
            }).AddUserStore<CustomUserStore>()
              .AddRoleStore<CustomRoleStore>(); 
Enter fullscreen mode Exit fullscreen mode

🔗 Links

linkedin
twitter

💖 💪 🙅 🚩
karimfahmy
Karim Fahmy

Posted on January 11, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related