This repository serves multiple purposes:
- Demonstrate "Decouple ASP.NET Core Identity, Authentication and Database Engines"
- Demonstrate "Share Identity Bear Tokens among ASP.NET Core Web APIs"
- Demonstrate "Resource Owner Password Credentials Grant and Refreshing Token with ASP.NET Core Identity"
- Provide some plugin components that decouple business modules from concrete SQL database engines.
- Provide some components that decouple ASP.NET Core Identity with concrete database engines.
- 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.
Provides a few libraries to decouple business modules from concrete SQL database engines:
- Fonlow.EntityFrameworkCore.Abstract
- Fonlow.EntityFrameworkCore.MySql
- Fonlow.EntityFrameworkCore.Sqlite
- Fonlow.EntityFrameworkCore.MsSql
- 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.
Provides a few libraries to create a database of ASP.NET Core Identity with a concrete database engine:
- Fonlow.AspNetCore.Identity
- Fonlow.AuthDbCreator
- 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:
- System.WebHttp.AuthorizeAttribute of .NET Framework
- System.Web.Mvc.AuthorizeAttribute of .NET Framework
- ...
- 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