JSON Web Tokens
JSON Web Tokens (JWTs) are digitally signed JSON objects based on the open standard RFC 7519. These tokens provide a compact, self-contained
method for securely transmitting information between parties. These tokens are
signed with an RSA-encoded public/private key pair. The signature is calculated
using the header and body, which enables the receiver to validate that the content
has not been tampered with.
A JWT takes the form of a string, and consists of three parts separated by dots:
<Header><Payload><Signature>
The header and payload is
Base64-encoded JSON
and contains these claims:- Header: The algorithm and token type. For example:{"kid": "zu", "alg": "RS256"}
- Payload: The claims of what the token represents. For example:{"sub": "1234567890", "name": "John Doe", "iat": 1516239022}
- Signature: The signature is computed from the header and payload using a secret or private key.
IMPORTANT
When working with JWTs,
Cybersource
recommends that you use a well- maintained JWT library to ensure proper decoding
and parsing of the JWT. IMPORTANT
When parsing the JWT’s JSON payload, you must ensure that you
implement a robust solution for transversing JSON. Additional elements can be
added to the JSON in future releases. Follow JSON parsing best practices to
ensure that you can handle the addition of new data elements in the future.