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
httpContext
HttpContextThe HttpContext instance for the current HTTP request.
jwtSecurityToken
JwtSecurityTokenThe 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
httpContext
HttpContextThe HttpContext instance for the current HTTP request.
accessToken
stringThe 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
accessToken
stringThe 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
httpContext
HttpContextThe HttpContext instance for the current HTTP request.
cancellationToken
CancellationTokenA token that can be used to cancel the operation (optional).