public void SignOut() { if (Request.IsAuthenticated) { string userId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; if (!string.IsNullOrEmpty(userId)) { // Get the user's token cache and clear it SessionTokenCache tokenCache = new SessionTokenCache(userId, HttpContext); tokenCache.Clear(); } } HttpContext.GetOwinContext().Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType); Response.Redirect("/"); }
public void SignOut() { if (Request.IsAuthenticated) { // Get the user's token cache and clear it string userObjId = AuthHelper.GetUserId(ClaimsPrincipal.Current); SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext); tokenCache.Clear(); } // Send an OpenID Connect sign-out request. HttpContext.GetOwinContext().Authentication.SignOut( CookieAuthenticationDefaults.AuthenticationType); Response.Redirect("/"); }
// Here we clear the token cache and end the session with the web app. public void SignOut() { if (Request.IsAuthenticated) { // Get the user's token cache and clear it. string userObjectId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; SessionTokenCache tokenCache = new SessionTokenCache(userObjectId, HttpContext); tokenCache.Clear(userObjectId); } // Send an OpenID Connect sign-out request. HttpContext.GetOwinContext().Authentication.SignOut( CookieAuthenticationDefaults.AuthenticationType); Response.Redirect("/"); }
public void SignOut() { if (Request.IsAuthenticated) { // Get the user's token cache and clear it string userObjId = System.Security.Claims.ClaimsPrincipal.Current .FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext); tokenCache.Clear(); } // Send an OpenID Connect sign-out request. HttpContext.GetOwinContext().Authentication.SignOut( CookieAuthenticationDefaults.AuthenticationType); Response.Redirect("/"); }
public void SignOut() { if (Request.IsAuthenticated) { // Get the user's token cache and clear it string userObjId = System.Security.Claims.ClaimsPrincipal.Current .FindFirst(Settings.AAD_OBJECTID_CLAIMTYPE).Value; SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext); tokenCache.Clear(); } // Send an OpenID Connect sign-out request. HttpContext.GetOwinContext().Authentication.SignOut( CookieAuthenticationDefaults.AuthenticationType); Response.Redirect("/"); }
public void SignOut() { if (Request.IsAuthenticated) { string userId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; if (!string.IsNullOrEmpty(userId)) { string appId = ConfigurationManager.AppSettings["ida:AppId"]; // Get the user's token cache and clear it SessionTokenCache tokenCache = new SessionTokenCache(userId, HttpContext); tokenCache.Clear(appId); } } // Send an OpenID Connect sign-out request. HttpContext.GetOwinContext().Authentication.SignOut( CookieAuthenticationDefaults.AuthenticationType); Response.Redirect("/"); }
public void SignOut() { if (Request.IsAuthenticated && ClaimsPrincipal.Current.FindFirst("aud").Value == Startup.AppId) { var userId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; if (!string.IsNullOrEmpty(userId)) { // Get the user's token cache and clear it var tokenCache = new SessionTokenCache(userId, HttpContext); tokenCache.Clear(); } } // Send an OpenID Connect sign-out request. HttpContext.GetOwinContext().Authentication.SignOut( CookieAuthenticationDefaults.AuthenticationType); Response.Redirect("/"); }