Esempio n. 1
0
        public async Task <PipelineContinuation> Operate(PipelineContext context)
        {
            var authenticationMechanisms = context.Application.AuthenticationMechanisms;

            IAuthTicket authTicket = null;
            IAuthenticationMechanism authenticationMechanism = null;

            foreach (var authMechanism in authenticationMechanisms)
            {
                authenticationMechanism = authMechanism;
                log.Debug("Trying to identify request using {authenticationMethod}", authMechanism);

                authTicket = await authMechanism.TryIdentify(context);

                if (authTicket != null)
                {
                    log.Debug("Request successfully identified using {authenticationMethod}", authMechanism);


                    context.SetAuthTicket(authTicket);
                    context.Items["__OriginalAuthTicket"]   = authTicket;
                    context.Items["__AuthenticationMethod"] = authMechanism;
                    break;
                }
            }

            if (context.Result != null)
            {
                log.Debug("{authenticationMethod} returned identification challenge, returning", authenticationMechanism.GetType());
                return(PipelineContinuation.SkipToPostHandler);
            }

            if (authTicket == null)
            {
                log.Debug("Request unidentified");

                authTicket = new AuthTicket();
                context.SetAuthTicket(authTicket);
                context.Items["__OriginalAuthTicket"]   = authTicket;
                context.Items["__AuthenticationMethod"] = null;
            }

            return(PipelineContinuation.Continue);
        }
Esempio n. 2
0
 bool Equals(AuthTicket other)
 {
     return(string.Equals(this.UserId, other.UserId) && this.IssuedOn.Equals(other.IssuedOn) && string.Equals(this.Token, other.Token));
 }