Table of Contents

Class JwtAuthProvider

Namespace
JD.AI.Core.Security
Assembly
JD.AI.Core.dll

JWT bearer token authentication provider. Validates HMAC-SHA256 signed JWT tokens and extracts identity claims.

public sealed class JwtAuthProvider : IAuthProvider
Inheritance
JwtAuthProvider
Implements
Inherited Members

Constructors

JwtAuthProvider(byte[], string, TimeSpan?)

public JwtAuthProvider(byte[] signingKey, string issuer = "jdai", TimeSpan? clockSkew = null)

Parameters

signingKey byte[]

HMAC-SHA256 signing key (minimum 32 bytes).

issuer string

Expected issuer claim. Tokens with different issuers are rejected.

clockSkew TimeSpan?

Tolerance for clock differences. Default 5 minutes.

Methods

AuthenticateAsync(string, CancellationToken)

Validates a credential and returns the identity.

public Task<GatewayIdentity?> AuthenticateAsync(string credential, CancellationToken ct = default)

Parameters

credential string
ct CancellationToken

Returns

Task<GatewayIdentity>

IssueToken(string, string, GatewayRole, TimeSpan?)

Issues a JWT token for the given identity.

public string IssueToken(string subject, string displayName, GatewayRole role, TimeSpan? expiry = null)

Parameters

subject string
displayName string
role GatewayRole
expiry TimeSpan?

Returns

string