internal static async Task OnReturnEndpoint(TwitterReturnEndpointContext context) { if (context.Identity != null && context.SignInAsAuthenticationType == IdentityOptions.ExternalCookieAuthenticationType) { //This way we will know all notifications were fired. var manageStoreClaim = context.Identity.Claims.Where(c => c.Type == "ManageStore" && c.Value == "false").FirstOrDefault(); if (manageStoreClaim != null) { context.Identity.RemoveClaim(manageStoreClaim); context.Identity.AddClaim(new Claim("ManageStore", "Allowed")); } } await Task.FromResult(0); }
public async Task <bool> InvokeReturnPathAsync() { AuthenticationTicket model = await AuthenticateAsync(); if (model == null) { _logger.WriteWarning("Invalid return state, unable to redirect."); Response.StatusCode = 500; return(true); } var context = new TwitterReturnEndpointContext(Context, model) { SignInAsAuthenticationType = Options.SignInAsAuthenticationType, RedirectUri = model.Properties.RedirectUri }; model.Properties.RedirectUri = null; await Options.Provider.ReturnEndpoint(context); if (context.SignInAsAuthenticationType != null && context.Identity != null) { ClaimsIdentity signInIdentity = context.Identity; if (!string.Equals(signInIdentity.AuthenticationType, context.SignInAsAuthenticationType, StringComparison.Ordinal)) { signInIdentity = new ClaimsIdentity(signInIdentity.Claims, context.SignInAsAuthenticationType, signInIdentity.NameClaimType, signInIdentity.RoleClaimType); } Context.Authentication.SignIn(context.Properties, signInIdentity); } if (!context.IsRequestCompleted && context.RedirectUri != null) { if (context.Identity == null) { // add a redirect hint that sign-in failed in some way context.RedirectUri = WebUtilities.AddQueryString(context.RedirectUri, "error", "access_denied"); } Response.Redirect(context.RedirectUri); context.RequestCompleted(); } return(context.IsRequestCompleted); }
public async Task <bool> InvokeReturnPathAsync() { var model = await HandleAuthenticateOnceAsync(); if (model == null) { Logger.LogWarning("Invalid return state, unable to redirect."); Response.StatusCode = 500; return(true); } var context = new TwitterReturnEndpointContext(Context, model) { SignInScheme = Options.SignInScheme, RedirectUri = model.Properties.RedirectUri }; model.Properties.RedirectUri = null; await Options.Notifications.ReturnEndpoint(context); if (context.SignInScheme != null && context.Principal != null) { await Context.Authentication.SignInAsync(context.SignInScheme, context.Principal, context.Properties); } if (!context.IsRequestCompleted && context.RedirectUri != null) { if (context.Principal == null) { // add a redirect hint that sign-in failed in some way context.RedirectUri = QueryHelpers.AddQueryString(context.RedirectUri, "error", "access_denied"); } Response.Redirect(context.RedirectUri); context.RequestCompleted(); } return(context.IsRequestCompleted); }
/// <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(TwitterReturnEndpointContext context) { return(OnReturnEndpoint(context)); }
public Task ReturnEndpoint(TwitterReturnEndpointContext context) { return(Task.FromResult <object>(null)); }