How to verify FID token
Struct of a normal token
A JWT is combined from 3 parts, separated by period ‘.’ character. All three parts are base64url-coded (not base64) of actual data.
header: JSON object reposent signature algorithm, keyid. Example:
Fid currently uses the “RS256” algorithm.
payload: JSON object with JWT claims. Example:
signature: Signature of first two parts of the JWT, using algorithm and key from header. With “RS256” algorithm, signature can be computed as follow:
Step to verify JWT
Preparing: Get certificates from authority. In OIDC, certificates can be obtained from an jwks url, which defined from oidc configuration. Example:
Authority:
${domain}
Example jwks:
An authority can have multiple certificates and can be changed at most 2 times per day. A recommended way is to cached jwks and refresh once per 1 hour.
Check expiration time: check if “exp” claim in payload is not later than current time,
Check authority: check if “iss” claim in payload is a valid authority. The list of valid authorities can be configured before,
Verify signature:
Check if algorithm is RS256,
Check if “kid” field in header is from certificates cache. If the authority has multiple certificates, pick the one with same “kid”,
Use the certificate to verify signature, i.e check if
Last updated