DEV Community

Karim Fahmy
Karim Fahmy

Posted on • Edited on

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

Top comments (0)