Understanding & Using Microsoft Identity

615 Views Asked by At

Background: I'm developing my first enterprise software solution as a part of starting my software company. I'm developing on .NET Core.

I've been reading through all of the Microsoft documentation regarding Authentication vs. Authorization, AzureAD, Identity Server hosted, etc..

I'm struggling to understand some of the larger design philosophies and strategies around users in the modern environment of OAuth 2.0 where another service Authenticates the user and sends back claims.

Current State: Currently, I am able to login using Blazor and AzureAD with Microsoft accounts. When a user logs in, I get their user identifier using HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier) on the request, which may have additional claims like their name or email. Since I'm not using Identity hosted where the user data is stored on a local database.

Questions regarding interacting with Microsoft Identity / AzureAD

  1. If I want code to execute after the user logs in, using their login data, how is one supposed to do that? An example use case: User has a 'theme' associated with their account. They login, and I want code to run that applies that theme into the DOM for them after login
  2. User data modeling? Since a user authenticates with another service who says "yes, this person is authenticated", my service basically has no information about them. I want to store info associated with the NameIdentifier I get back from the auth service so that I can build a "profile" for this person. A use case for this is:

Taylor White logs into Enterprise News Service Inc.. He comments on an article, the comment is saved with a string UserId, and string CommentContent. When someone goes to that article though, I want to pull information about Taylor, like his name and photo, but I don't have any database currently modeling the user or storing the claims that I get back from the identity provider.

In short, what am I missing regarding these scenarios?

  • Performing some logic after a successful login
  • Best practices for storing user data from an identity provider and accessing it in other contexts like loading comments from different users.

Additional Info:

  • I'm using Blazor WebAssembly for my front-end which also runs on .NET.
  • I'm using a .NET Core backend.
0

There are 0 best solutions below