Skip to content

Unable to extract claims when cty specified in JWS header (>0.12.0) #897

Open
@icecreamhead

Description

@icecreamhead

Describe the bug
In 0.11.5 and below, the Claims object can be extracted from JWS regardless of whether the cty field is set on header or not.
From 0.12.0 onwards, if the cty header is set, an exception is thrown when attempting to extract the Claims object, even when the content type is json.
The behaviour appears to have changed in this PR. The change is clearly driven by the RFC but I don't believe the jjwt library should automatically throw an exception in this scenario. We have no control over whether the client has included the cty field or not, but if they specify json, then I think we should continue to parse the claims as if the field weren't specified at all.

To Reproduce
Any attempt to invoke DefaultJwtParser#parseSignedClaims() when the supplied JWS has the cty field set results in io.jsonwebtoken.UnsupportedJwtException: Unexpected content JWS.. This occurs even if the specified content type is json.

Expected behavior
The claims are parsed successfully and returned from the method.

Screenshots
Old, expected behaviour (0.11.5)

image

New, unexpected behaviour (0.12.3)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions