.Net Core Notes Chimera Tech - Apr 2023
Jwt Token Expire Time
While creating token add this Expires = DateTime.UtcNow.AddMinutes(_jwtLifetime)
var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = new ClaimsIdentity(new Claim[]
{
new Claim("application_id", applicationId.ToString()),
new Claim(ClaimTypes.Role, String.Join(",", role)),
new Claim("district_id", districtId),
new Claim("school_id", authenticateModel.SchoolId),
}),
Expires = DateTime.UtcNow.AddMinutes(_jwtLifetime),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature),
Issuer = _jwtIssuer,
Audience = audience
};
tokenDescriptor.Subject.AddClaim(new Claim("user_id", userId));
tokenPayNowModel = tokenHandler.CreateToken(tokenDescriptor);
-------------------------------------------
How to expire previous toke
- keep log in separate table
Comments
Post a Comment