Esempio n. 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));
        }
Esempio n. 2
0
 public RefreshToken(AuthenConfig authenticationConfiguration, TokenGenerator tokenGenerator)
 {
     _authenConfig   = authenticationConfiguration;
     _tokenGenerator = tokenGenerator;
 }
Esempio n. 3
0
 public AccessToken(TokenGenerator tokenGenerator, AuthenConfig configuration)
 {
     _tokenGenerator = tokenGenerator;
     _configuration  = configuration;
 }