Class JwtVerifier
- Namespace
- KernLab.Claim.Client
- Assembly
- KernLab.Claim.Client.dll
JWT 本地验证器(消费方 SDK 面——与核心库同语义的独立实现:分层纪律,Client 不背引擎)。 alg 白名单 → kid 定位(JWKS 缓存,未命中即刷)→ 验签 → 时间窗 → iss/aud。
public sealed class JwtVerifier
- Inheritance
-
JwtVerifier
- Inherited Members
Constructors
JwtVerifier(JwksFetcher, TimeSpan?)
构造。
public JwtVerifier(JwksFetcher fetcher, TimeSpan? clockSkew = null)
Parameters
fetcherJwksFetcherclockSkewTimeSpan?
Methods
VerifyAsync(string, string, string?, DateTimeOffset?, CancellationToken)
验证并解出 claims——失败抛 ClaimClientException。
aud 强制校验(契约 §4 / G11——★16):expectedAudience 必填,
token 缺 aud claim 或不符即拒——「验签必带 aud」在 API 面写死,无绕过入口。
public Task<VerifiedToken> VerifyAsync(string token, string expectedAudience, string? expectedIssuer = null, DateTimeOffset? utcNow = null, CancellationToken cancellationToken = default)
Parameters
tokenstringJWS 紧凑序列化。
expectedAudiencestring期望受众(必填——本方签发的 token aud 恒绑定 client_id)。
expectedIssuerstring非空则校验 iss。
utcNowDateTimeOffset?当前时刻(测试时钟注入点)。
cancellationTokenCancellationToken取消。