Table of Contents

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 HttpContext

The HttpContext instance for the current HTTP request.

jwtSecurityToken JwtSecurityToken

The 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 HttpContext

The HttpContext instance for the current HTTP request.

accessToken string

The 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 string

The 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 HttpContext

The HttpContext instance for the current HTTP request.

cancellationToken CancellationToken

A token that can be used to cancel the operation (optional).

Returns

Task<string>

A task that represents the asynchronous operation, with a result of the refreshed access token.