Beispiel #1
0
        internal string GenerateToken(AuthenConfig _configuration, string SecretKey, double tokenExpirationMinutes, List <Claim> claims = null)
        {
            SecurityKey        authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(SecretKey));;
            SigningCredentials credentials    = new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256);;

            SecurityToken token = new JwtSecurityToken(
                issuer: _configuration.ValidIssuer,
                audience: _configuration.ValidAudience,
                claims: claims,
                expires: DateTime.Now.AddMinutes(tokenExpirationMinutes),
                signingCredentials: credentials
                );;;

            return(new JwtSecurityTokenHandler().WriteToken(token));
        }
 public RefreshToken(AuthenConfig authenticationConfiguration, TokenGenerator tokenGenerator)
 {
     _authenConfig   = authenticationConfiguration;
     _tokenGenerator = tokenGenerator;
 }
 public AccessToken(TokenGenerator tokenGenerator, AuthenConfig configuration)
 {
     _tokenGenerator = tokenGenerator;
     _configuration  = configuration;
 }