Skip to content

TokenTypePolicy Class

Which typ header values (RFC 7515 section 4.1.9) a validation accepts, so that a token signed for one purpose cannot be presented as another by a recipient trusting the same issuer for several (RFC 8725 section 3.11).

C#
public sealed record TokenTypePolicy : System.IEquatable<Abblix.Jwt.TokenTypePolicy>

Inheritance System.Object → TokenTypePolicy

Implements System.IEquatable<TokenTypePolicy>

Remarks

Every validation states one: TokenTypes has no default, because a default that skipped the check would leave a type unchecked without anybody deciding it should be.

Matching is case-insensitive and accepts either spelling of the application/ prefix on either side, so at+jwt and application/AT+JWT name the same type, as RFC 7515 section 4.1.9 requires of a media type.

Fields

TokenTypePolicy.CheckedByCaller Field

Leaves the typ header to the caller, which judges it after validation, as a deliberate and named choice rather than a missing setting.

C#
public static readonly TokenTypePolicy CheckedByCaller;

Field Value

TokenTypePolicy

Properties

TokenTypePolicy.Rule Property

How the typ header is judged.

C#
public Abblix.Jwt.TokenTypeRule Rule { get; }

Property Value

TokenTypeRule

TokenTypePolicy.Types Property

The accepted typ values; empty for CheckedByCaller, and for OrUntyped(string[]) when only a token without a type is accepted.

C#
public System.Collections.Generic.IReadOnlyList<string> Types { get; }

Property Value

System.Collections.Generic.IReadOnlyList<System.String>

Methods

TokenTypePolicy.Exactly(string[]) Method

Accepts a token whose typ names one of types, and refuses one without a type.

C#
public static Abblix.Jwt.TokenTypePolicy Exactly(params string[] types);

Parameters

types System.String[]

The accepted values, at least one.

Returns

TokenTypePolicy

TokenTypePolicy.OrUntyped(string[]) Method

Accepts a token whose typ names one of types or that carries no typ, for a token whose specification leaves its type optional. With no types, only an untyped token is accepted.

C#
public static Abblix.Jwt.TokenTypePolicy OrUntyped(params string[] types);

Parameters

types System.String[]

The accepted values besides absence.

Returns

TokenTypePolicy