-1

I am aware of Azure Active Directory, but not sure where to start.. or if it's the best option.

I have a .NET core App (deployed to Azure WebApp). I want to secure this app with o365 auth. When the person has logged in, I need to be able to track each request to the API based on a token.

I'm not sure if this is as simple as it sounds on- is it?

Thank you.

Jim G.
  • 15,141
  • 22
  • 103
  • 166
  • It is very easy to Authenticate a user against Azure AD. When you start a new project you can select Azure AD as the authentication type and it wires it all up, you just have to provide your specific app registration details - client id, tenant, etc. But that is a separate issue from tracking based on a token. You might consider asking two questions. – Crowcoder Jul 08 '20 at 11:52
  • I don't HAVE to track it with a token, but I need some kind of way to be able to track the requests too and from the Controller - any suggestions? – discreetcycle Jul 08 '20 at 12:01
  • "Track Requests" is vague. What specifically do you want to track? If you add Application Insights to your app you will automatically get request tracing but I don't know if that is what you want. Your question is too vague and too broad to answer. – Crowcoder Jul 08 '20 at 12:03
  • Sorry about that. Let me try and clarify; I have a multi-tenant App. I need to know WHO is hitting the end point, and their access rights etc. – discreetcycle Jul 08 '20 at 12:05

1 Answers1

0

Managed to answer my own question. Assuming the person has Authenticated w/ O365:

var identity = ((ClaimsIdentity)HttpContext.User.Identity);
var name = identity.Claims.FirstOrDefault(c => c.Type == "name")?.Value;
var email = identity.Claims.FirstOrDefault(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;