private async Task <bool> InvokeReturnPathAsync()
        {
            _logger.WriteVerbose("InvokeReturnPath");

            var model = await AuthenticateAsync();

            var context = new QQConnectReturnEndpointContext(Context, model);

            context.SignInAsAuthenticationType = Options.SignInAsAuthenticationType;
            context.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)
            {
                Response.Redirect(context.RedirectUri);
                context.RequestCompleted();
            }

            return(context.IsRequestCompleted);
        }
Ejemplo n.º 2
0
        private async Task <bool> InvokeReturnPathAsync()
        {
            _logger.WriteVerbose("InvokeReturnPath");

            var model = await AuthenticateAsync();

            var context = new QQConnectReturnEndpointContext(Context, model);

            context.SignInAsAuthenticationType = Options.SignInAsAuthenticationType;
            context.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.Request.User = new ClaimsPrincipal(signInIdentity);
                //Context.Authentication.SignIn(context.Properties, signInIdentity);
            }

            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");
                }
                Context.Request.Headers.Add("x-redirect", new string[] { redirectUri });
                //Response.Redirect(redirectUri);
                //context.RequestCompleted();
            }

            return(false);//context.IsRequestCompleted;
        }
Ejemplo n.º 3
0
 public Task ReturnEndpoint(QQConnectReturnEndpointContext context)
 {
     return(onReturnEndpoint(context));
 }