/// <summary> /// Sign out the specified authentication scheme. /// </summary> /// <param name="context">The <see cref="HttpContext"/>.</param> /// <param name="scheme">The name of the authentication scheme.</param> /// <param name="properties">The <see cref="AuthenticationProperties"/>.</param> /// <returns>A task.</returns> public virtual async Task SignOutAsync(HttpContext context, string?scheme, AuthenticationProperties?properties) { if (scheme == null) { var defaultScheme = await Schemes.GetDefaultSignOutSchemeAsync(); scheme = defaultScheme?.Name; if (scheme == null) { throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultSignOutScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action<AuthenticationOptions> configureOptions)."); } } var handler = await Handlers.GetHandlerAsync(context, scheme); if (handler == null) { throw await CreateMissingSignOutHandlerException(scheme); } var signOutHandler = handler as IAuthenticationSignOutHandler; if (signOutHandler == null) { throw await CreateMismatchedSignOutHandlerException(scheme, handler); } await signOutHandler.SignOutAsync(properties); }
/// <summary> /// Sign out the specified authentication scheme. /// </summary> /// <param name="context">The <see cref="ProtoContext"/>.</param> /// <param name="scheme">The name of the authentication scheme.</param> /// <param name="properties">The <see cref="AuthenticationProperties"/>.</param> /// <returns>A task.</returns> public virtual async Task SignOutAsync(ProtoContext context, string scheme, AuthenticationProperties properties) { if (scheme == null) { var defaultScheme = await Schemes.GetDefaultSignOutSchemeAsync(); scheme = defaultScheme?.Name; if (scheme == null) { throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultSignOutScheme found."); } } var handler = await Handlers.GetHandlerAsync(context, scheme); if (handler == null) { throw await CreateMissingSignOutHandlerException(scheme); } if (!(handler is IAuthenticationSignOutHandler signOutHandler)) { throw await CreateMismatchedSignOutHandlerException(scheme, handler); } await signOutHandler.SignOutAsync(properties); }
public override async Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) { var defaultScheme = await Schemes.GetDefaultSignOutSchemeAsync(); if (scheme == null || scheme == defaultScheme.Name) { _session.RemoveSessionIdCookie(); } await base.SignOutAsync(context, scheme, properties); }
/// <summary>Sign out the specified authentication scheme.</summary> /// <param name="context">The <see cref="T:Microsoft.AspNetCore.Http.HttpContext" />.</param> /// <param name="scheme">The name of the authentication scheme.</param> /// <param name="properties">The <see cref="T:Microsoft.AspNetCore.Authentication.AuthenticationProperties" />.</param> /// <returns>A task.</returns> public virtual async Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) { if (scheme == null) { var signOutSchemeAsync = await Schemes.GetDefaultSignOutSchemeAsync(); scheme = signOutSchemeAsync?.Name; if (scheme == null) { throw new InvalidOperationException("No authenticationScheme was specified, and there was no DefaultSignOutScheme found."); } } if (!(await Handlers.GetHandlerAsync(context, scheme) is IAuthenticationSignOutHandler handlerAsync)) { throw new InvalidOperationException(string.Format("No IAuthenticationSignOutHandler is configured to handle sign out for the scheme: {0}", scheme)); } var properties1 = properties; await handlerAsync.SignOutAsync(properties1); }
/// <summary> /// Sign out the specified authentication scheme. /// </summary> /// <param name="context">The <see cref="HttpContext"/>.</param> /// <param name="scheme">The name of the authentication scheme.</param> /// <param name="properties">The <see cref="AuthenticationProperties"/>.</param> /// <returns>A task.</returns> public virtual async Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) { if (scheme == null) { var defaultScheme = await Schemes.GetDefaultSignOutSchemeAsync(); scheme = defaultScheme?.Name; if (scheme == null) { throw new InvalidOperationException($"No authenticationScheme was specified, and there was no DefaultSignOutScheme found."); } } var handler = await Handlers.GetHandlerAsync(context, scheme) as IAuthenticationSignOutHandler; if (handler == null) { throw new InvalidOperationException($"No IAuthenticationSignOutHandler is configured to handle sign out for the scheme: {scheme}"); } await handler.SignOutAsync(properties); }