JwtAuthManager
RevokeRefreshToken
Revokes the specified refresh token for the user, called when logged out.
- Parameters:
userId(string): The unique identifier of the user.refreshToken(string): The refresh token to be revoked.
GenerateTokens
Generates an access token and a refresh token for the specified user and claims.
Parameters:
userId(string): The unique identifier of the user.claims(Claim[]): An array of claims to be included in the tokens.now(DateTime): The current date and time.
Returns:
- A
JwtAuthResultobject containing the generated access token and refresh token.
- A
Refresh
Refreshes the access token using the provided refresh token and access token.
Parameters:
refreshToken(string): The refresh token used for refreshing the access token.accessToken(string): The access token to be refreshed.now(DateTime): The current date and time.
Returns:
- A tuple containing the user ID as a string and a
JwtAuthResultobject containing the refreshed access token and refresh token.
- A tuple containing the user ID as a string and a
DecodeJwtToken
Decodes and validates the provided JWT token.
Parameters:
token(string): The JWT token to be decoded and validated.validateLifetime(bool): Determines whether to validate the token's lifetime. Default istrue.
Returns:
- A tuple containing the
ClaimsPrincipalrepresenting the token's claims and theJwtSecurityTokenobject representing the decoded token.
- A tuple containing the
The JwtAuthResult class represents the result of JWT authentication.
Properties
AccessToken(string): The access token.RefreshToken(RefreshToken): The refresh token.
The RefreshToken class represents a refresh token.
Properties
UserId(string): The user ID associated with the refresh token.TokenString(string): The refresh token string.ExpireAt(DateTime): The expiration date and time of the refresh token.
