http://localhost:3000/callback
.http://localhost:3000
.Auth0.AspNetCore.Authentication
Nuget package to your application.Program.cs
file and call builder.Services.AddAuth0WebAppAuthentication()
to register the
SDK’s middleware.Ensure to configure the Domain
and ClientId
, these are required fields to ensure the
SDK knows which Auth0 tenant and application it should use.Make sure you have enabled authentication and authorization in your Program.cs
file.Login
action to your controller.Call HttpContext.ChallengeAsync()
and pass Auth0Constants.AuthenticationScheme
as the
authentication scheme. This will invoke the OIDC authentication handler that our SDK registers internally. Be sure
to also specify the corresponding authenticationProperties
, which you can construct using the
LoginAuthenticationPropertiesBuilder
.After succesfully calling HttpContext.ChallengeAsync()
, the user will be redirected to Auth0 and
signed in to both the OIDC middleware and the cookie middleware upon being redirected back to your application.
This will allow the users to be authenticated on subsequent requests.Login
action will redirect to Auth0User.Claims
property on the controller.You can create a custom user profile page for displaying a user’s name, email address, and profile image, by
retrieving the corresponding information from the User
and pass it to the view from inside your
controller.Profile
action after being succesfully logged in, shows the user’s
profile.HttpContext.SignOutAsync
with
the CookieAuthenticationDefaults.AuthenticationScheme
authentication scheme from inside your
controller’s action.Additionally, If you also want to log the user out from Auth0 (this might also log them out of other applications
that rely on Single Sign On), call HttpContext.SignOutAsync
with the
Auth0Constants.AuthenticationScheme
authentication scheme as well as the appropriate
authenticationProperties
that can be constructed using the
LogoutAuthenticationPropertiesBuilder
.Logout
action will ensure the user is logged out.