예제 #1
0
        // 生成Token通用
        private string CreateToken(List <Claim> claims, EnumTokenType tokenType)
        {
            var key     = new SymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes(_mbpConfigs.Value.Jwt.SecurityKey));
            var expires = tokenType == EnumTokenType.AccessToken ? DateTime.Now.AddMinutes(_mbpConfigs.Value.Jwt.TimeOut)
                : DateTime.Now.AddMinutes(_mbpConfigs.Value.Jwt.RefreshTimeOut);

            var token = new JwtSecurityToken(
                issuer: _mbpConfigs.Value.Jwt.Issuer,
                audience: tokenType == EnumTokenType.AccessToken ? _mbpConfigs.Value.Jwt.Audience : "refreshToken",
                claims: claims,
                notBefore: DateTime.Now,
                expires: expires,
                signingCredentials: new SigningCredentials(key, SecurityAlgorithms.HmacSha256));

            return(new JwtSecurityTokenHandler().WriteToken(token));
        }
예제 #2
0
 public Token(string value, EnumTokenType type)
 {
     this.value = value;
     this.type  = type;
 }
예제 #3
0
 public TokenFilter(EnumTokenType enumTokenType)
 {
     _enumTokenType = enumTokenType;
 }
예제 #4
0
 public Token(string text, EnumTokenType type)
 {
     this.text = text;
     this.type = type;
 }