Interface IOpenSettingsTokenService
- Namespace
- OpenSettings.AspNetCore
- Assembly
- OpenSettings.AspNetCore.dll
Defines methods for handling and managing OpenSettings token validation and refresh functionality. This service provides functionality for checking token expiration, reading JWT tokens, and refreshing tokens.
public interface IOpenSettingsTokenService
Methods
IsTokenExpiredAsync(HttpContext, JwtSecurityToken)
Checks if the specified JWT security token has expired.
Task<bool> IsTokenExpiredAsync(HttpContext httpContext, JwtSecurityToken jwtSecurityToken)
Parameters
httpContextHttpContextThe HttpContext instance for the current HTTP request.
jwtSecurityTokenJwtSecurityTokenThe JwtSecurityToken to check for expiration.
Returns
- Task<bool>
A task that represents the asynchronous operation, with a result indicating whether the token is expired.
IsTokenExpiredAsync(HttpContext, string)
Checks if the specified access token has expired.
Task<bool> IsTokenExpiredAsync(HttpContext httpContext, string accessToken)
Parameters
httpContextHttpContextThe HttpContext instance for the current HTTP request.
accessTokenstringThe access token to check for expiration.
Returns
- Task<bool>
A task that represents the asynchronous operation, with a result indicating whether the token is expired.
ReadJwtToken(string)
Reads the specified access token and returns the corresponding JwtSecurityToken.
JwtSecurityToken ReadJwtToken(string accessToken)
Parameters
accessTokenstringThe access token to read.
Returns
- JwtSecurityToken
The decoded JwtSecurityToken.
RefreshTokenAsync(HttpContext, CancellationToken)
Refreshes the access token asynchronously.
Task<string> RefreshTokenAsync(HttpContext httpContext, CancellationToken cancellationToken = default)
Parameters
httpContextHttpContextThe HttpContext instance for the current HTTP request.
cancellationTokenCancellationTokenA token that can be used to cancel the operation (optional).