private async Task <bool> InvokeReplyPathAsync() { if (Options.CallbackPath.HasValue && Options.CallbackPath == Request.Path) { // TODO: error responses AuthenticationTicket ticket = await AuthenticateAsync(); if (ticket == null) { _logger.WriteWarning("Invalid return state, unable to redirect."); Response.StatusCode = 500; return(true); } var context = new FacebookReturnEndpointContext(Context, ticket); context.SignInAsAuthenticationType = Options.SignInAsAuthenticationType; context.RedirectUri = ticket.Properties.RedirectUri; await Options.Provider.ReturnEndpoint(context); if (context.SignInAsAuthenticationType != null && context.Identity != null) { ClaimsIdentity grantIdentity = context.Identity; if (!string.Equals(grantIdentity.AuthenticationType, context.SignInAsAuthenticationType, StringComparison.Ordinal)) { grantIdentity = new ClaimsIdentity(grantIdentity.Claims, context.SignInAsAuthenticationType, grantIdentity.NameClaimType, grantIdentity.RoleClaimType); } Context.Authentication.SignIn(context.Properties, grantIdentity); } if (!context.IsRequestCompleted && context.RedirectUri != null) { string redirectUri = context.RedirectUri; if (context.Identity == null) { // add a redirect hint that sign-in failed in some way redirectUri = WebUtilities.AddQueryString(redirectUri, "error", "access_denied"); } Response.Redirect(redirectUri); context.RequestCompleted(); } return(context.IsRequestCompleted); } return(false); }
private async Task <bool> InvokeReplyPath() { _logger.WriteVerbose("InvokeReplyPath"); if (Options.ReturnEndpointPath != null && String.Equals(Options.ReturnEndpointPath, Request.Path, StringComparison.OrdinalIgnoreCase)) { // TODO: error responses AuthenticationTicket ticket = await Authenticate(); var context = new FacebookReturnEndpointContext(Request.Environment, ticket, ErrorDetails); context.SignInAsAuthenticationType = Options.SignInAsAuthenticationType; context.RedirectUri = ticket.Extra.RedirectUrl; await Options.Provider.ReturnEndpoint(context); if (context.SignInAsAuthenticationType != null && context.Identity != null) { ClaimsIdentity grantIdentity = context.Identity; if (!string.Equals(grantIdentity.AuthenticationType, context.SignInAsAuthenticationType, StringComparison.Ordinal)) { grantIdentity = new ClaimsIdentity(grantIdentity.Claims, context.SignInAsAuthenticationType, grantIdentity.NameClaimType, grantIdentity.RoleClaimType); } Response.Grant(grantIdentity, context.Extra); } if (!context.IsRequestCompleted && context.RedirectUri != null) { string redirectUri = context.RedirectUri; if (ErrorDetails != null) { redirectUri = WebUtilities.AddQueryString(redirectUri, ErrorDetails); } Response.Redirect(redirectUri); context.RequestCompleted(); } return(context.IsRequestCompleted); } return(false); }
public virtual Task ReturnEndpoint(FacebookReturnEndpointContext context) { return OnReturnEndpoint(context); }
/// <summary> /// Invoked prior to the <see cref="System.Security.Claims.ClaimsIdentity"/> being saved in a local cookie and the browser being redirected to the originally requested URL. /// </summary> /// <param name="context"></param> /// <returns>A <see cref="Task"/> representing the completed operation.</returns> public virtual Task ReturnEndpoint(FacebookReturnEndpointContext context) { return(OnReturnEndpoint(context)); }
public override Task ReturnEndpoint(FacebookReturnEndpointContext context) { return Task.FromResult<object>(null); }