-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A single audience value gets converted into a set with one entry #890
Comments
Just for some background context for the current ( The single-string The RFC spec committee later changed the This poses a frustrating challenge for Java libraries that are strongly-typed, where people don't like their data types changing randomly. So, starting in Based on the reported behavior, the problem at the moment is that the In other words, the 'last call wins' as to the behavior seen. Based on this it seems as if generic As you've indicated, there is a workaround for this for applications - just call the We'll use this ticket to track the work to implement this special case logic. Thank you for opening it! |
…hout converting it to a `Set`) when copying/applying a source Claims instance to a destination Claims builder. Updated CHANGELOG.md accordingly. Fixes #890.
Sorry but, I don't get how can I build a JWT with a single String AUD. Is it possible now? or just legacy copy supports? |
@gomesar9 It's possible in JJWT 0.12.4 and later via: Jwts.builder().claims().audience().single("test").and()... |
Oh, okay. My editor still point it as "deprecated". |
It is indeed deprecated to discourage its use; application developers shouldn't be using the single String value approach anymore - it was a legacy behavior and the finalized RFC recommends a String array. Ideally all applications should change to the String array approach when possible because 1) it is more flexible, allowing multiple recipients and 2) reduces complexity since recipients would no longer need to always perform the "Is it a String? Or array of Strings?" type conversion/checking logic. |
Describe the bug
In the scenario when we first build claims with
DefaultClaimsBuilder
and then pass them toJwtBuilder
, a single audience value gets converted somewhere on the way fromString
toSet<String>
. This is a breaking change for the APIs, which expect a string audience value.To Reproduce
Steps to reproduce the behavior:
String
):jwtBuilder
; this time it'sSet<String>
):Expected behavior
In case of using
audience().single(...)
the type of theaudience
claim should stayString
after callingclaims(...)
on the JWT builder.Workaround
Note, if setting the claim directly on the JWT builder, the type is preserved:
The text was updated successfully, but these errors were encountered: