Microsoft.Owin.Security.OpenIdConnect
Nuget package.http://localhost:3000/callback
.http://localhost:3000
.Microsoft.Owin.Security.OpenIdConnect
and Microsoft.Owin.Security.Cookies
Nuget packages.Web.config
:auth0:Domain
: The domain of your Auth0 tenant. You can find this in the Auth0 Dashboard under your application’s **Settings **in the Domain field. If you are using a custom domain, set this to the value of your custom domain instead.auth0:ClientId
: The ID of the Auth0 application you created in Auth0 Dashboard. You can find this in the Auth0 Dashboard under your application’s **Settings **in the Client ID field.Login
action to your controller.Call HttpContext.GetOwinContext().Authentication.Challenge
and pass "Auth0"
as the authentication scheme. This invokes the OIDC authentication handler that was registered earlier. Be sure to specify the corresponding AuthenticationProperties
, including a RedirectUri
.After successfully calling HttpContext.GetOwinContext().Authentication.Challenge
, the user redirects 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 Auth0HttpContext.GetOwinContext().Authentication.SignOut
with the CookieAuthenticationDefaults.AuthenticationType
authentication scheme to log the user out of your application.Additionally, if you 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.GetOwinContext().Authentication.SignOut
with the "Auth0"
authentication scheme.Logout
action ensures the user is logged out.ClaimsIdentity
. Access the extracted information by using the User
property on the controller.To create a user profile, retrieve a user’s name, email address, and profile image from the User
and pass it to the view from inside your controller.Profile
action after being successfully logged in, shows the user’s profile.