-
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
Jwts.builder - audience cannot be add without calling add() #916
Comments
Hi @michal-trnka! Thanks for the issue (and especially the test case!). This is very helpful. For what it's worth, the concept of nested builders and using
Also individual @Override
public JwtBuilder issuer(String iss) {
return claims().issuer(iss).and();
} But I definitely understand how it may not be clear that one must call the So we'll use this issue to track the work to address this. There are two solutions:
I think my preference is the first solution if we can make this work easily and there are no negative side-effects. I'll have to do some testing. Thanks again for the issue! |
…d to apply collection changes. Instead, changes are applied immediately as they occur (via `.add`, `.remove`, etc), and `.and()` is now purely for returning to the parent builder if necessary/desired. * Updated associated JavaDoc with code examples to make the `.and()` method's purpose a little clearer. * Updated CHANGELOG.md Closes #916
Many thanks for the thorough explanation! I have just again tested claims to be sure. It accepts the following code snipped. I guess this is what made me confused most.
I'd prefer option # 2. However, adding it to JavaDoc would make the behavior more transparent and would work for me too. |
@michal-trnka after looking at the code, I went with the first option in PR #917 and it worked out well - no surprises or 'penalties' to work around. There was partly a strong reason to apply changes immediately, not the least of which is that it didn't 'hurt' anything, but also it avoids problems with method chains like: .header().add("foo", "bar");
// sometime later:
.header().empty().critical()... If we didn't apply changes immediately when |
* Ensured `NestedCollection`s do not need their `.and()` method called to apply collection changes. Instead, changes are applied immediately as they occur (via `.add`, `.remove`, etc), and `.and()` is now purely for returning to the parent builder if necessary/desired. * Updated associated JavaDoc with code examples to make the `.and()` method's purpose a little clearer. * Updated CHANGELOG.md Closes #916
This is now released in |
Awesome, thanks a lot for fixing that! |
Describe the bug
When using builder to create a token adding audience needs to be followed by
and()
. This behaviour is not documented and it is inconsistent (eg. claims do not need that).To Reproduce
Try to add audience to a builder by calling
builder.audience().add("my-web")
;Test case:
Expected behavior
Adding audience to a builder does not need to be followed by
and()
The text was updated successfully, but these errors were encountered: