Skip to content

DefaultJwtParser ignores custom base64 parser it was built with in a scenario #947

@mbomeara

Description

@mbomeara

In cases where a JwtParser is built using b64Url() to provide a custom base64 decoder, the expectation is that all base64 decoding will use the custom decoder:

Jwts.parser()
    .verifyWith(publicKey)
    .b64Url(decoder) // expect this decoder to be used for all base64 operations of parseSignedClaims()
    .build()
    .parseSignedClaims(jwt);

However due to

jwt = new DefaultJws<>(jwsHeader, body, base64UrlDigest.toString());
a new DefaultJws is constructed. The constructor for DefaultJws is hard-coded to use its own base64 decoder (namely Decoders.BASE64URL):

super(header, payload, Decoders.BASE64URL.decode(signature), DIGEST_NAME);

This violates the expectation that the custom base64 decoder will be used for all decoding. This behavior has changed somewhere between 0.11.5 and 0.12.5 which in turn breaks our application if we update our jjwt dependency version to the latest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions