Skip to content

Libraries for utilizing ASP.NET Identity and Entity Framework Core, neutral to database engines

Notifications You must be signed in to change notification settings

zijianhuang/AuthEF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository serves multiple purposes:

  1. Demonstrate "Decouple ASP.NET Core Identity, Authentication and Database Engines"
  2. Demonstrate "Share Identity Bear Tokens among ASP.NET Core Web APIs"
  3. Demonstrate "Resource Owner Password Credentials Grant and Refreshing Token with ASP.NET Core Identity"
  4. Provide some plugin components that decouple business modules from concrete SQL database engines.
  5. Provide some components that decouple ASP.NET Core Identity with concrete database engines.
  6. Demonstrate how to craft integration tests and run on local dev PC as much as possible, and the artifacts could be easily reused in a team CI server like GitHub Actions/Workflow.

Decoupling Entity Framework and DB Engines

Provides a few libraries to decouple business modules from concrete SQL database engines:

  1. Fonlow.EntityFrameworkCore.Abstract
  2. Fonlow.EntityFrameworkCore.MySql
  3. Fonlow.EntityFrameworkCore.Sqlite
  4. Fonlow.EntityFrameworkCore.MsSql
  5. Fonlow.EntityFrameworkCore.PostgreSQL

Therefore, through altering a connection string in the app settings, your app can switch to another DB engine during deployment, along with the plugin assembly and its dependencies.

Hints:

  • It should be quick and easy for you to write Fonlow.EntityFrameworkCore.MyFavoriteDbEngine for MS SQL or Oracle etc.

ASP.NET Core Identity

Provides a few libraries to create a database of ASP.NET Core Identity with a concrete database engine:

  1. Fonlow.AspNetCore.Identity
  2. Fonlow.AuthDbCreator
  3. Fonlow.WebApp.Accounts

Please read the readme.md file of each library.

Hints:

  • Even if you don't use ASP.NET Core Identity for authentication, but something like Okta, Auth0 or Azure AD / MS Entra ID, doupling main business modules from the authentication implementation is beneficial to CI and business, and having a locally hosted ASP.NET Core Identity implementation makes integration tests fast as explained below.
  • Microsoft has provided similar classes out of the box from libraries or scaffolding codes of ASP.NET MVC, however, using string for ID, while these libraries use GUID.

===Article later ===========

Microsoft .NET Framework and .NET Core have provided architectural design for application programmer to decouple the concrete implementation of authentication from the main business logic codes, through a class named AuthorizeAttribute in variety of its development frameworks:

  1. System.WebHttp.AuthorizeAttribute of .NET Framework
  2. System.Web.Mvc.AuthorizeAttribute of .NET Framework
  3. ...
  4. Microsoft.AspNetCore.Authorization.AuthorizeAttribute

In addition to the architectural design, such naming convention through name "AthorizeAttribute" makes code migrations and switching authentication mechanism even easier.

Remarks:

The decoupling in WCF goes through different approach, as described on https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/authentication-in-wcf

About

Libraries for utilizing ASP.NET Identity and Entity Framework Core, neutral to database engines

Resources

Stars

Watchers

Forks

Packages

No packages published