示例#1
0
        public static (bool valid, List <Claim> claims) VerifyToken(string token, string secretKey, Managers.SecretType secretType)
        {
            Managers.IAuthService authService = new Managers.JWTService(secretKey, secretType);
            bool valid = authService.IsTokenValid(token);

            if (valid)
            {
                return(true, authService.GetTokenClaims(token).ToList());
            }
            return(false, null);
        }
示例#2
0
        public static string CreateToken(string user, string codutente, Managers.SecretType secretType)
        {
            IAuthContainerModel model;

            if (secretType == Managers.SecretType.RSAKey)
            {
                model = GetJWTContainerModelRsa(user, codutente);
            }
            else
            {
                model = GetJWTContainerModelPassword(user, codutente);
            }
            System.Diagnostics.Debug.Write($"Password { model.SecretKey} _{user}_{codutente}_");
            Managers.IAuthService authService = new Managers.JWTService(model.SecretKey, secretType);
            return(authService.GenerateToken(model));
        }