private async Task LogoutRedirectAsync(AuthenticationProperties properties)
 {
     // Redirect response to logout
     Response.Redirect(
         (await KeycloakIdentity.GenerateLogoutUriAsync(Options, Request.Uri, new Uri(properties.RedirectUri)))
         .ToString());
 }
        /// <summary>
        /// Method logs generates the logout url for the realm and performs a user log out
        /// and issues a redirection to the login page for the user to enter credentials again.
        /// </summary>
        /// <param name="identity">Current identity signed in keycloak. It will be forced log out.</param>
        /// <returns>Redirection to login page</returns>
        private async Task ForceLogoutRedirectAsync(ClaimsIdentity identity)
        {
            // generate logout uri
            var uri = await KeycloakIdentity.GenerateLogoutUriAsync(Options, Request.Uri);

            //foreach (var claim in identity.Claims)
            //{
            //    _logger.Debug($"ForceLogoutRedirectAsync user claim {claim.Type} - {claim.Value}");
            //}

            _logger.Debug($"Force logout identity with isAuthenticated:{identity.IsAuthenticated}");

            Claim firstOrDefault = identity.Claims.FirstOrDefault(claim => claim.Type == "refresh_token");

            if (firstOrDefault != null)
            {
                await OidcDataManager.HttpLogoutPost(firstOrDefault.Value, Options, uri);
            }

            //redirect to relogin
            var challenge = Helper.LookupChallenge(Options.AuthenticationType, Options.AuthenticationMode);

            if (challenge == null)
            {
                _logger.Debug($"Force logged out {identity.Name}.Challenge is null.Return.");
                return;
            }

            _logger.Debug($"Force logged out {identity.Name}.Redirecting from challenge properties.");
            await LoginRedirectAsync(challenge.Properties);
        }
        private async Task LogoutRedirectAsync()
        {
            // Redirect response to logout
            var temp = (await KeycloakIdentity.GenerateLogoutUriAsync(Options, Request.Uri)).ToString();

            Response.Redirect(temp);
        }
Exemplo n.º 4
0
 private async Task LogoutRedirectAsync()
 {
     // Redirect response to logout
     Response.Redirect(
         (await
          KeycloakIdentity.GenerateLogoutUriAsync(Context, Options, Request.Uri))
         .ToString());
 }
 private async Task LogoutRedirectAsync()
 {
     // Redirect response to logout
     Response.Redirect((await KeycloakIdentity.GenerateLogoutUriAsync(Options, new Uri(CurrentUri))).ToString());
 }