Skip to main content

AuthServiceJwtFormatter Class

Abblix.Oidc.Server

Abblix.Oidc.Server.Features.Tokens.Formatters

AuthServiceJwtFormatter Class

Provides functionality to format and sign JSON Web Tokens (JWTs) specifically for use within the authentication service. This class processes tokens issued by the authentication service itself, including access tokens, refresh tokens and Registration Access Tokens generated during client registration via the dynamic registration API. It leverages signing and optional encryption to generate JWTs that authenticate and authorize internal service operations.

public class AuthServiceJwtFormatter : Abblix.Oidc.Server.Features.Tokens.Formatters.IAuthServiceJwtFormatter

Inheritance System.Object → AuthServiceJwtFormatter

Implements IAuthServiceJwtFormatter

Constructors

AuthServiceJwtFormatter(IJsonWebTokenCreator, IAuthServiceKeysProvider, IOptions<OidcOptions>) Constructor

Provides functionality to format and sign JSON Web Tokens (JWTs) specifically for use within the authentication service. This class processes tokens issued by the authentication service itself, including access tokens, refresh tokens and Registration Access Tokens generated during client registration via the dynamic registration API. It leverages signing and optional encryption to generate JWTs that authenticate and authorize internal service operations.

public AuthServiceJwtFormatter(Abblix.Jwt.IJsonWebTokenCreator jwtCreator, Abblix.Oidc.Server.Common.Interfaces.IAuthServiceKeysProvider serviceKeysProvider, Microsoft.Extensions.Options.IOptions<Abblix.Oidc.Server.Common.Configuration.OidcOptions> options);

Parameters

jwtCreator IJsonWebTokenCreator

The service responsible for creating and issuing JWTs.

serviceKeysProvider IAuthServiceKeysProvider

The provider that supplies cryptographic keys used for signing and encrypting JWTs.

options Microsoft.Extensions.Options.IOptions<OidcOptions>

OIDC configuration options.

Methods

AuthServiceJwtFormatter.FormatAsync(JsonWebToken) Method

Formats and signs a JWT for use by the authentication service, applying the appropriate cryptographic operations based on the JWT specified requirements and the available cryptographic keys.

public System.Threading.Tasks.Task<string> FormatAsync(Abblix.Jwt.JsonWebToken token);

Parameters

token JsonWebToken

The JSON Web Token (JWT) to be formatted and signed, potentially also encrypted.

Implements FormatAsync(JsonWebToken)

Returns

System.Threading.Tasks.Task<System.String>
A task that returns the JWT formatted as a string.

Remarks

This method selects the appropriate signing key based on the algorithm specified in the JWT header. If encryption is supported and keys are available, it also encrypts the JWT. The result is a JWT string that is ready for use in authenticating and authorizing service operations, including access tokens, refresh tokens and Registration Access Tokens.