コード例 #1
0
        private JwtSecurityToken CreateJwtSecurityToken(JwtTokenOptions tokenOptions, User user, SigningCredentials signingCredentials, string[] roles)
        {
            var jwt = new JwtSecurityToken(
                issuer: tokenOptions.Issuer,
                audience: tokenOptions.Audience,
                expires: _tokenExpiration,
                notBefore: DateTime.Now,
                claims: SetClaims(user, roles),
                signingCredentials: signingCredentials
                );

            return(jwt);
        }
コード例 #2
0
 public JwtTokenHelper(IConfiguration configuration)
 {
     Configuration    = configuration;
     _tokenOptions    = Configuration.GetSection("TokenOptions").Get <JwtTokenOptions>();
     _tokenExpiration = DateTime.Now.AddMinutes(_tokenOptions.TokenExpiration);
 }