Documentation
¶
Overview ¶
Package token manipulates and inspects tokens for the authentication cases (FR-CASE-10) and the expiry check (FR-AUTH-06). It never verifies signatures and needs no key.
Index ¶
Constants ¶
const TruncateLen = 100
TruncateLen is how many characters of the real token Truncate keeps.
Variables ¶
This section is empty.
Functions ¶
func Expiry ¶
Expiry returns the "exp" claim of a JWT. ok is false for other tokens or tokens without "exp". The token is decoded, not verified.
func IsJWT ¶
IsJWT reports whether tok looks like a JWS in compact form (header.payload.signature) with a decodable signature.
func Tamper ¶
Tamper returns a copy of tok that must be rejected by any server that validates tokens. It differs from tok as much as possible while keeping its form, so a cache or proxy keyed on parts of the token cannot mistake it for the real one.
For a JWT the header stays, so the server still picks the real key. The payload keeps all claims and gets the claim "apitest": "invalid-token", and every byte of the decoded signature is inverted. Other tokens get every second character replaced by a different character of the same kind.
Types ¶
This section is empty.