public Task RemoteError(AdfsErrorContext context) { return OnRemoteError(context); }
protected virtual async Task <bool> HandleRemoteCallbackAsync() { // TODO: error responses AuthenticationTicket ticket = await AuthenticateAsync().ConfigureAwait(false); if (ticket == null) { var errorContext = new AdfsErrorContext(Context, new Exception("Invalid return state, unable to redirect.")); _logger.WriteWarning($"{Options.AuthenticationType}: Error from RemoteAuthentication: " + errorContext.Error.Message); await Options.Events.RemoteError(errorContext).ConfigureAwait(false); if (errorContext.HandledResponse) { return(true); } if (errorContext.Skipped) { return(false); } Context.Response.StatusCode = 500; return(true); } var context = new AdfsTicketReceivedContext(Context, Options, ticket); // REVIEW: is this safe or good? ticket.Properties.RedirectUri = null; await Options.Events.TicketReceived(context).ConfigureAwait(false); if (context.HandledResponse) { _logger.WriteVerbose($"{Options.AuthenticationType}: The TicketReceived event returned Handled."); return(true); } if (context.Skipped) { _logger.WriteVerbose($"{Options.AuthenticationType}: The TicketReceived event returned Skipped."); return(false); } if (context.Identity != null) { Context.Authentication.SignIn(context.Properties, context.Identity); } // Default redirect path is the base path if (string.IsNullOrEmpty(context.ReturnUri)) { context.ReturnUri = "/"; } if (string.IsNullOrEmpty(context.ReturnUri)) { return(false); } string uri = context.ReturnUri; if (context.Identity == null) { // add a redirect hint that sign-in failed in some way uri = WebUtilities.AddQueryString(uri, "error", "access_denied"); } Response.Redirect(uri); context.HandleResponse(); return(true); }
public Task RemoteError(AdfsErrorContext context) { return(OnRemoteError(context)); }