Ejemplo n.º 1
0
        public void LogUserIn(string username, IIdentity userIdentity)
        {
            var identity = claimsIdentityFactory.GetIdentity(username,
                                                             userIdentity,
                                                             DefaultAuthenticationTypes.ApplicationCookie);

            authenticationManager.SignIn(new AuthenticationProperties()
            {
                AllowRefresh = true,
                IsPersistent = true,
            }, identity);
        }
Ejemplo n.º 2
0
        public void CheckAuthentication(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var request = loginRequestCreator(context.UserName, context.Password, context.Request.RemoteIpAddress);

            var result = (Agiil.Auth.IAuthenticationResult)authService.Authenticate(request.GetCredentials());

            if (!result.Success)
            {
                context.SetError(InvalidGrant, AuthenticationFailureMessage);
                context.Rejected();
                return;
            }

            var identity = claimsIdentityFactory.GetIdentity(result, JwtBearerTokenAuthenticationType);
            var ticket   = new AuthenticationTicket(identity, new AuthenticationProperties());

            context.Validated(ticket);
        }