Adding Identity Server
Duende IdentityServer6 is a standards-compliant OpenID Connect and oAuth 2.0 framework for aspnetcore.
More References
Sample Application
Code Changes
-
DuendeIdentityServer6.csproj - Added the IdentityServer6 application.
-
Config.cs - Added SampleApi1 and SampleApi2 to the scope. Requests to SampleApi1 and SampleApi2 will now require authentication
-
SampleApi1 and SampleApi2 - Program.cs is now configured with Authentication and Authorization and the Controllers now have the authorize attrbute.
-
Dockerfile, docker-compose - Docker files and the docker-compose files have now been updated to add the new DuendeIdentityServer6 project.
-
Directory.Packages.props - The solution now uses the Central Package Management system.
Verification
-
Go to the swagger location of SampleApi1 using:- http://docker.for.linux.localhost:5023/swagger
-
Testing the
PersonController
should return NotAuthorized. -
Login using the Authorize button on the top-right corner of the page.
-
Now testing the
PersonController
should return the values.