protected virtual Task HandleSignOutAsync(SignOutContext context) { return(Task.FromResult(0)); }
/// <summary> /// Handles Signout /// </summary> /// <returns></returns> protected override async Task HandleSignOutAsync(SignOutContext signout) { if (signout != null) { if (_configuration == null && Options.ConfigurationManager != null) { _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); } var message = new OpenIdConnectMessage() { IssuerAddress = _configuration == null ? string.Empty : (_configuration.EndSessionEndpoint ?? string.Empty), }; // Set End_Session_Endpoint in order: // 1. properties.Redirect // 2. Options.PostLogoutRedirectUri var properties = new AuthenticationProperties(signout.Properties); var logoutRedirectUri = properties.RedirectUri; if (!string.IsNullOrEmpty(logoutRedirectUri)) { // Relative to PathBase if (logoutRedirectUri.StartsWith("/", StringComparison.Ordinal)) { logoutRedirectUri = BuildRedirectUri(logoutRedirectUri); } message.PostLogoutRedirectUri = logoutRedirectUri; } else if (!string.IsNullOrEmpty(Options.PostLogoutRedirectUri)) { logoutRedirectUri = Options.PostLogoutRedirectUri; // Relative to PathBase if (logoutRedirectUri.StartsWith("/", StringComparison.Ordinal)) { logoutRedirectUri = BuildRedirectUri(logoutRedirectUri); } message.PostLogoutRedirectUri = logoutRedirectUri; } message.IdTokenHint = await Context.Authentication.GetTokenAsync(OpenIdConnectParameterNames.IdToken); var redirectContext = new RedirectContext(Context, Options, properties) { ProtocolMessage = message }; await Options.Events.RedirectToIdentityProviderForSignOut(redirectContext); if (redirectContext.HandledResponse) { Logger.RedirectToIdentityProviderForSignOutHandledResponse(); return; } else if (redirectContext.Skipped) { Logger.RedirectToIdentityProviderForSignOutSkipped(); return; } message = redirectContext.ProtocolMessage; if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.RedirectGet) { var redirectUri = message.CreateLogoutRequestUrl(); if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) { Logger.InvalidLogoutQueryStringRedirectUrl(redirectUri); } Response.Redirect(redirectUri); } else if (Options.AuthenticationMethod == OpenIdConnectRedirectBehavior.FormPost) { var inputs = new StringBuilder(); foreach (var parameter in message.Parameters) { var name = HtmlEncoder.Encode(parameter.Key); var value = HtmlEncoder.Encode(parameter.Value); var input = string.Format(CultureInfo.InvariantCulture, InputTagFormat, name, value); inputs.AppendLine(input); } var issuer = HtmlEncoder.Encode(message.IssuerAddress); var content = string.Format(CultureInfo.InvariantCulture, HtmlFormFormat, issuer, inputs); var buffer = Encoding.UTF8.GetBytes(content); Response.ContentLength = buffer.Length; Response.ContentType = "text/html;charset=UTF-8"; // Emit Cache-Control=no-cache to prevent client caching. Response.Headers[HeaderNames.CacheControl] = "no-cache"; Response.Headers[HeaderNames.Pragma] = "no-cache"; Response.Headers[HeaderNames.Expires] = "-1"; await Response.Body.WriteAsync(buffer, 0, buffer.Length); } } }
protected override async Task HandleSignOutAsync(SignOutContext context) { await Context.Authentication.SignOutAsync(Options.Cookies.ApplicationCookie.AuthenticationScheme); await base.HandleSignOutAsync(context); }
protected override Task HandleSignOutAsync(SignOutContext context) { throw new NotSupportedException(); }
public override Task SignOutAsync(SignOutContext context) { return(Task.FromResult(0)); }
public sealed override Task SignOutAsync(SignOutContext context) { return(SignOutAsync(context, OwinContext.Request.CallCancelled)); }
protected override async Task HandleSignOutAsync(SignOutContext context) { // request may be null when no logout request has been received // or has been already handled by InvokeLogoutEndpointAsync. var request = Context.GetOpenIdConnectRequest(); if (request == null) { return; } // Stop processing the request if there's no signout context that matches // the authentication type associated with this middleware instance // or if the response status code doesn't indicate a successful response. if (context == null || Response.StatusCode != 200) { return; } if (Response.HasStarted) { Logger.LogCritical( "OpenIdConnectServerHandler.TeardownCoreAsync cannot be called when " + "the response headers have already been sent back to the user agent. " + "Make sure the response body has not been altered and that no middleware " + "has attempted to write to the response stream during this request."); return; } // post_logout_redirect_uri is added to the response message since it can be // set or replaced from the ValidateClientLogoutRedirectUri event. var response = new OpenIdConnectMessage { PostLogoutRedirectUri = request.PostLogoutRedirectUri, State = request.State }; var notification = new LogoutEndpointResponseContext(Context, Options, request, response); await Options.Provider.LogoutEndpointResponse(notification); if (notification.HandledResponse) { return; } // Stop processing the request if no explicit // post_logout_redirect_uri has been provided. if (string.IsNullOrEmpty(response.PostLogoutRedirectUri)) { return; } var location = response.PostLogoutRedirectUri; foreach (var parameter in response.Parameters) { // Don't include post_logout_redirect_uri in the query string. if (string.Equals(parameter.Key, OpenIdConnectParameterNames.PostLogoutRedirectUri, StringComparison.Ordinal)) { continue; } location = QueryHelpers.AddQueryString(location, parameter.Key, parameter.Value); } Response.Redirect(location); }
public Task SignOutAsync(SignOutContext context) { context.Accept(); return(Task.CompletedTask); }
public virtual Task SignOutAsync(SignOutContext context) { PriorHandler?.SignOutAsync(context); return(Task.CompletedTask); }
public Task SignOutAsync(SignOutContext context) { new OwinContext(_oes.Environment).Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(Task.FromResult(0)); }
// Base does nothing public override Task SignOutAsync(SignOutContext context) { return(base.SignOutAsync(context)); }
public async Task SignOutAsync(SignOutContext context) { await this.inMemoryUserService.SignOutAsync(context); }
public async Task SignOutAsync(SignOutContext context) { await domainService.SignOutAsync(context.Subject, context.ClientId); }
public Task SignOutAsync(SignOutContext context) { return(Task.FromResult(true)); }
/// <summary> /// This method gets called when the user signs out. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public Task SignOutAsync(SignOutContext context) { return(inner.SignOutAsync(context)); }
public async Task SignOutAsync(SignOutContext context) { }
public Task SignOutAsync(SignOutContext context) { SignedIn = false; context.Accept(); return(Task.FromResult(0)); }
public Task SignOutAsync(SignOutContext context) { return(_handler.SignOutAsync(context)); }
public virtual Task SignOutAsync(SignOutContext context, CancellationToken cancellationToken) { return(base.SignOutAsync(context)); }
public sealed override Task SignOutAsync(SignOutContext context) { return(SignOutAsync(context, CurrentCancellationToken)); }
/// <summary> /// Handles signout /// </summary> /// <param name="context"></param> /// <returns></returns> protected override async Task HandleSignOutAsync(SignOutContext context) { if (context == null) { return; } Logger.LogTrace($"Entering {nameof(WsFederationAuthenticationHandler)}'s HandleSignOutAsync"); if (_configuration == null && Options.ConfigurationManager != null) { _configuration = await Options.ConfigurationManager.GetConfigurationAsync(Context.RequestAborted); } var wsFederationMessage = new WsFederationMessage { IssuerAddress = _configuration.TokenEndpoint ?? string.Empty, Wtrealm = Options.Wtrealm, Wa = WsFederationActions.SignOut }; var properties = new AuthenticationProperties(context.Properties); if (!string.IsNullOrEmpty(properties?.RedirectUri)) { wsFederationMessage.Wreply = properties.RedirectUri; } else if (!string.IsNullOrWhiteSpace(Options.SignOutWreply)) { wsFederationMessage.Wreply = Options.SignOutWreply; } else if (!string.IsNullOrWhiteSpace(Options.Wreply)) { wsFederationMessage.Wreply = Options.Wreply; } var redirectContext = new RedirectContext(Context, Options) { ProtocolMessage = wsFederationMessage }; await Options.Events.RedirectToIdentityProvider(redirectContext); if (redirectContext.HandledResponse) { Logger.LogDebug("RedirectContext.HandledResponse"); return; } if (redirectContext.Skipped) { Logger.LogDebug("RedirectContext.Skipped"); return; } var redirectUri = redirectContext.ProtocolMessage.CreateSignOutUrl(); if (!Uri.IsWellFormedUriString(redirectUri, UriKind.Absolute)) { Logger.LogWarning($"The sign-out redirect URI is malformed: {redirectUri}"); } Response.Redirect(redirectUri); }
public override Task SignOutAsync(SignOutContext context) { SignOutWasCalled = true; return(base.SignOutAsync(context)); }
protected override Task HandleSignOutAsync(SignOutContext context) { return(Task.FromResult(0)); }
/// <summary> /// This method gets called when the user signs out. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public virtual Task SignOutAsync(SignOutContext context) { return(Task.FromResult(0)); }
public Task SignOutAsync(SignOutContext context) { throw new NotImplementedException(); }
public override Task SignOutAsync(SignOutContext context) { //TODO Investigate if there is a endpoint on azure ad return(base.SignOutAsync(context)); }