Skip to content

Demonstrates how to add Identity to existing Blazor Server projects.

Notifications You must be signed in to change notification settings

akhanalcs/blazor-server-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Blazor Server Identity Examples

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.

Getting started

  1. Clone the repo.

  2. Launch the app. It will initialize the Db on Startup using Data/DbInitializer.cs

  3. If you want to login as a test user, the credentials are inside: Data/DbInitializer.cs file.

    For eg: Email -> handyman@coolapp, Password -> Password123!

Branch: feature/LayoutWithIdentityPages

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:

  1. How to fit the Identity Razor Pages in the Blazor app to give consistent look and feel when the user navigates between Razor Pages (coming from Identity Razor Package) and Razor Components.
  2. How to implement Revalidation.
  3. How to implement RedirectToLogin so users are directed to Login page if they aren't authenticated and need to access authenticated page.

Branch: feature/AddUserManagementPages

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: image image image

I'll write more about how I implemented it (step-by-step) at a later date when I get some time.

Branch: feature/AddADAuthentication

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

Branch: feature/AddClaimsDuringLogin

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. image

About

Demonstrates how to add Identity to existing Blazor Server projects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published