Skip to content

Authentication explained

Jon P Smith edited this page Jun 20, 2022 · 4 revisions

ASP.NET Core breaks up the handling of logged-in users into two parts:

  1. Authentication, which holds a list of valid users, say by email, and their credentials, such as a password, so that when they log in it can confirm that someone is who they says they are. It also manages where the logged-in users details are held, e.g. Cookie or JWT Token.
  2. Authorization, which uses the logged-in users details to define what features that user can access within the application.

The AuthP library relies on the various authentication providers in ASP.NET Core. These authentication providers break down into two types:

  • Local authentication providers: ASP.NET Core has a Individual User Accounts authentication providers which holds user's email and password using a database and handles the login/validation of users. This approach has been around for many years and provides a simple solution. NOTE: you can create your own version of this local authentication provider - see this article.
  • External authentication providers: These work by providing an external service that holds the user's definition (e.g. email and credentials) and checks that the user that is logging is valid. These typically use OAuth2 and/or OpenId (see this article to explain these terms). There are many of these such as

Linking AuthP to an authentication provider

How AuthP links to an authentication provider depends on whether you are storing the logged-in user's details in a Cookie or you are using a JWT Token. If you are using AuthP's JWT Token Builder, then this will work with any type of authentication providers. But if you are using a Cookie to store the user's details, then you need to intercept the adding of claims to the cookie so that AuthP can add its extra claims to hold the user's Permissions and optionally its multi-tenant DataKey claim.

AuthP library has built-in link to the following ASP.NET Core authentication providers

  • Individual Accounts authentication provider via the IndividualAccountsAuthentication() extension method. This just works and needs little extra code from you.
  • Azure AD authentication provider via the IndividualAccountsAuthentication(...some data here...) extension method. This has some settings and options (see Setup Authentication about the options) that you need to set up (NOTE: I found setting up the Azure AD wasn't that simple)

What happens if I want to use AuthP with another authentication provider?

Over time I might add links to other ASP.NET Core authentication providers, but if your authentication provider uses OpenId (which most do), then you can copy how AuthP's Azure AD link to authentication provider, as all the external authentication providers follow the same pattern. I cover this in the Setup Authentication.

Next steps

Articles / Videos

Concepts

Setup

Usage

Admin

SupportCode

Clone this wiki locally