Class UnverifiedJsonWebToken
- Namespace
- MailFathom.Infrastructure.Security.OAuth
- Assembly
- MailFathom.Infrastructure.dll
Reads what a JSON Web Token says about itself, before anything has been verified.
public static class UnverifiedJsonWebToken
- Inheritance
-
UnverifiedJsonWebToken
- Inherited Members
Remarks
A deployment can trust several authorization servers and can accept a credential a client minted for itself, and the
token is the only thing that says which of them it is. Choosing what verifies it therefore has to read the token's
own iss claim, its own declared type, and its own kid header first — all three unsigned input, chosen
by whoever sent the request, and the name of this type says so at every call site.
What each value is allowed to decide is the point, and it is the same shape in all three: the value selects what
will check the signature, and never anything the signature was supposed to establish. iss and typ
select which configured profile validates the token, and that profile checks the signature against its own key set
and compares iss against its own configured issuer. kid selects a stored user-credential row, whose
registered public key is then what the signature is verified against — so an assertion naming a key registered for
another user is refused by that key's own signature check rather than admitted as that user, and one naming a
fingerprint nobody registered is refused exactly as one naming nothing. In every case the worst an attacker achieves
by writing whatever they like here is to pick which verifier rejects them.
Nothing else is read. The remaining claims are the validated token's business, and reading one here would make an unverified assertion look like an established fact somewhere further down.
Methods
- TryReadClaimedIssuer(ReadOnlySpan<char>, out string?)
Reads the issuer a compact-serialized JSON Web Token claims, from characters that are not a string.
- TryReadClaimedIssuer(string?, out string?)
Reads the issuer a compact-serialized JSON Web Token claims.
- TryReadDeclaredType(string?, out string?)
Reads the media type a compact-serialized JSON Web Token declares for itself.
- TryReadKeyId(string?, out string?)
Reads the key identifier a compact-serialized JSON Web Token names for the key that signed it.