A signature algorithm generates or verifies a signature on digital data. For a JWT, it signs the base64url-encoded header and payload, joined by a dot. Verification shows that the token remains intact and comes from the holder of the signing secret or private key. section 7.2.2 section 7.8
The JWT header’s alg value selects the algorithm, so accepting an attacker-controlled choice can undermine validation. Constrain accepted algorithms, use strong signing choices, and verify the signature on every request alongside the token’s claims. section 8.7 section 1.4
Common signing arrangements include:
- HS256 uses HMAC-SHA256 with one shared secret to create and verify the signature. section 7.2.2
- PS256 uses an asymmetric key pair: the issuer signs with the private key and validators verify with the public key. section 8.2 section 8.7
- A JWT library should support the required signing algorithms, while the application explicitly limits which algorithm it will accept. section 8.2 section 8.7
Issuing a PS256 token
Generate an RSA key pair with OpenSSL, load the private key, and pass it to PyJWT with algorithm="PS256". A receiving API uses the corresponding public key to verify the signature. section 8.7

