Class JwtHelper
Namespace: Identity.API.Utils
Assembly: Identity.API.dll
JWT class that define methods for JWT generation and management.
Inheritance
object ← JwtHelper
Implements
IJwtHelper
Inherited Members
object.Equals\(object?\), object.Equals\(object?, object?\), object.GetHashCode\(\), object.GetType\(\), object.MemberwiseClone\(\), object.ReferenceEquals\(object?, object?\), object.ToString\(\)
Constructors
JwtHelper\(IOptions<Jwt\>, IConfiguration\)
Class that define all method to manipulate and generate jwt tokens.
Parameters
jwtSettingsOptions IOptions < Jwt \>
- Jwt options stored on appsettings file and injection via Options pattern.
configuration IConfiguration
Configuration of the project builder.
Methods
GenerateJwt\(IEnumerable<Claim\>\)
Method that generate a jwt.
Parameters
claims IEnumerable < Claim \>
Claims to be encoded in the jwt.
Returns
The jwt token.
GenerateJwtFromUser\(User\)
Method that generates a jwt from a Identity.Domain.Aggregates.UserAggregate.User.
Parameters
user User
The user that the jwt is generated from.
Returns
The jwt response to return.
GenerateRefreshToken\(\)
Method to generate a refresh token for an expired token.
Returns
The refresh token.
GetPrincipalFromExpiredToken\(string\)
Get the principal claims from an expired token.
Parameters
token string
The expired token.
Returns
The System.Security.Claims.ClaimsPrincipal of the token.
Exceptions
Exception thrown if the security algorithm used do not match the Microsoft.IdentityModel.Tokens.SecurityAlgorithms.