UseCookieAuthentication
. The second is the OIDC middleware which is done with the call to UseOpenIdConnectAuthentication
.
Once the user has signed in to Auth0 using the OIDC middleware, their information will automatically be stored inside a . All you need to do is to configure the middleware as above and it will take care of managing the user session.
The Connect (OIDC) middleware will also extract all the claims from the , which is sent from Auth0 once the user has authenticated, and add them as claims on the ClaimsIdentity
.
SignOutAsync
method of the AuthenticationManager
class, and passing along the authentication scheme from which you want to sign out.
As an example to sign out of the cookie middleware, and thereby clearing the authentication cookie for your application, you can make the following call:
SignOutAsync
method and passing along Auth0
as the authentication scheme to sign out of.
OnRedirectToIdentityProviderForSignOut
event. Inside the event you will need to redirect to the Auth0 logout endpoint which will clear the Auth0 cookie.
Admin
users by decorating the claim with the [Authorize(Roles = "Admin")]
attribute. You can also check whether a user is in a specific role from code by making a call to User.IsInRole("Admin")
from inside your controller.
The ASP.NET OIDC middleware will automatically add all claims returned in the as claims to the ClaimsIdentity
. We would therefore need to extract the information from the authorization
claim, deserialize the JSON body of the claim, and for each of the groups add a http://schemas.microsoft.com/ws/2008/06/identity/claims/role
claim to the ClaimsIdentity
.