ASP.NET Identity Claims - getting started

David Thielen 2,776 Reputation points
2023-05-25T19:29:32.73+00:00

Hi all;

First off, among other pages I have read this and this.

I have ASP.NET Identity working well on my Blazor server app for Identification. I'm now on to the Authorization part and have a couple of questions.

My app is handling volunteers for political campaigns. So user A may be an admin for "Dave for President" and "Shirley for Senate" while user B is an admin for "Shirley for Senate" and "Tanya for CD-3".

Because they have an admin claim, they can go to the CreateEvent page. But their specific claims determine both which events they see as well as which they can create events for (just for the campaigns they're an admin of).

So, a couple of questions:

  1. Is there a good intro anywhere explaining how to set this all up. Both CRUD of the claims as well as then using those to determine if a page can be accessed, and then programmatically limiting data/actions on the page? On Blazor server.
  2. I found a great example of handling CRUD for the claims (I think it was MVC but that is 90% of the effort for Blazor server) - and I lost it. If you know where this is, please post the link.
  3. What are the trade-offs of having a single Claim("admin", "Dave for President;Shirley for Senate") vs having two: Claim("admin", "Dave for President") and Claim("admin", "Shirley for Senate")?
  4. Am I missing anything? Or is this all simply determining access of pages and conditional selection of data and functionality on a page?
  5. Should I be using Roles at all? Or just Claims?

thanks - dave

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,382 questions
{count} votes