IdentityServer4 Configuration— ASP.NET Core 3.1
Introduction
IdentityServer4 is an OpenID Connect and OAuth 2.0 framework for ASP.NET Core.
Features
Authentication as a Service
Single Sign-on / Sign-out
Access Control for APIs
Installation
Add ASP.NET Core 3.1 project and install the IdentityServer4 through Package Manager Console or NuGet
PM> Install-Package IdentityServer4 -Version 4.1.1
Startup.cs
In the Startup.cs file add the IdentityServer configuration as below
Configure Resources & Clients
Now next task is to configure the Clients & resources.
Clients can be of various types
Implicit, Client Credentials, Code
Also configure Identity Resources & Api Scopes as
Run the application
When all configurations are set, START the project and you will see Identity Server home page like below.
In this home page you will see the discovery document — where all the registered clients, endpoints, issuer information, api scopes, identity resources are placed.
The discovery endpoint can be used to retrieve metadata about your IdentityServer, it returns information like the issuer name, key material, supported scopes etc.
https://localhost:5001/.well-known/openid-configuration
Test the Identity Server
To test the identity server, add another project say ASP.NET Core MVC Client project and do all the configurations , set the Authority, add the Client Id, Client Secret & Response Type. Also add the required scopes.
Run the MVC project nd you will see Login Screen of Identity Server, Enter the credentials and all your way.
Happy Coding!!