This repo has examples related to doing Auth in Blazor Server. You can navigate to different branches to try different scenarios.
It's a basic Blazor Server app that comes out of the box (You can use Visual Studio or command line to create it).
I just added Identity to it following directions from here.
Data/DbInitializer.cs
If you want to login as a test user, the credentials are inside: Data/DbInitializer.cs
file.
For eg: Email -> handyman@coolapp, Password -> Password123!
This is the end result of me following the documentation and figuring out the rest of the missing pieces in the documentation. The missing pieces are:
RedirectToLogin
so users are directed to Login page if they aren't authenticated and need to access authenticated page.This branch builds up on the previous branch and adds pages to manage users, roles and permissions.
This follows the concepts explained by Jason Taylor in his video.
Just launch the app. The credentials are in the Data/DbInitializer.cs
file. Use them to login as admin and you can see these pages:
I'll write more about how I implemented it (step-by-step) at a later date when I get some time.
This branch builds up on the previous branch and adds capability to do Authentication using Local Active Directory.
This answer explains what I'm doing here: https://stackoverflow.com/a/74734478/8644294
This branch builds up on feature/LayoutWithIdentityPages to show how to add Claims during Login (in Login.cshtml.cs
file) and access those claims from Razor Component.
When you launch the app, login and click 'Break' and add a breakpoint in this line, you should get the new claim set in this line.