Skip to content

2.0.0

Latest

Choose a tag to compare

@PhilJay PhilJay released this 26 Sep 17:15

Version 2.0 is a security release with breaking changes. Please read the migration notes below.

Security fixes

  • JWT.verify in 1.x only checked the signature. It accepted expired tokens and tokens issued for other apps. The new JWT.verifyApple and JWT.verify also check exp, nbf, iat, iss, aud and the nonce, and return a JWTVerificationResult with the reason for a rejection.
  • ES256 signatures are now in the JWS format (64 bytes R || S). 1.x produced DER signatures, which strict verifiers reject.
  • Verification never throws on malformed input.
  • JWK kty, alg, use and kid are checked. RSA keys need at least 2048 bits, EC keys the matching curve. The header alg must match the signing algorithm. none and HMAC are rejected.
  • Strict base64url decoding, so a signature has exactly one valid form.
  • Tokens longer than 16 KB are rejected before decoding (configurable).

New

  • JWT.verifyApple for Sign in with Apple identity tokens.
  • JWT.appleClientSecret for the Sign in with Apple REST API.
  • ES384, ES512, RS384, RS512 and EC JWKs.
  • Keys.privateKey / Keys.publicKey read PEM keys, with or without header and footer. Signing accepts a loaded PrivateKey.
  • JWKSet, JWKObject.fromPublicKey, and exp, nbf, aud (String or array), sub, jti on JWTAuthPayload.
  • README examples for Gson, Jackson, a Sign in with Apple backend, APNs and issuing your own tokens.

Migrating from 1.x

  • Requires Java 17.
  • Remove the Base64Encoder / Base64Decoder and charset arguments. Base64url and UTF-8 are built in.
  • JWT.verify(jwt, jwk, decoder) is now JWT.verifySignature(jwt, jwk). For Sign in with Apple use JWT.verifyApple.
  • JWKObject.toRSA is now toPublicKey. toRSAString was removed.
  • decode returns null for anything that is not a signed token with three parts. It does not verify the token.
  • Payload claims are nullable.
implementation 'com.github.PhilJay:JWT:2.0.0'