Ejemplo n.º 1
0
        public async Task <AuthenticateResult> AuthenticateAsync()
        {
            string token = Context.Request.Cookies[_cookie_name];

            var(ok, tokenInfo) = await TokenIsValid(token);

            if (!ok)
            {
                token           = Context.Request.Headers["Authorization"];
                (ok, tokenInfo) = await TokenIsValid(token);

                if (!ok)
                {
                    return(AuthenticateResult.NoResult());
                }
            }

            var principal = await _tokenService.BuildPrincipal(token, tokenInfo);

            await RefreshCookie(token, tokenInfo);

            return(AuthenticateResult.Success(new AuthenticationTicket(principal, HopexAuthenticationDefaults.AuthenticationScheme)));
        }