Comments (1)
Just for some background context for the current (0.12.0
+) behavior:
The single-string aud
ience claim was implemented in JJWT before JWT RFC 7519 was finalized, and the RFC draft spec used at the time when implementing JJWT said aud
was a single StringOrURI
value, e.g. see RFC 7519, draft 5, section 4.1.5
The RFC spec committee later changed the aud
data type to be, in the general/normal/standard case a JSON array of StringOrURI
values, but then they said it may also be a single StringOrURI
(non-array) value, presumably to ensure existing usages could still be supported. See the now-finalized RFC 7519, Section 4.1.3.
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 0.12.0
, we added the .audience()
builder to help support this odd 'type-changing' use case, and the parser will always 'normalize' a single value into a Set<String>
so the app developer doesn't have to perform weird type conversion logic/checks in their application code.
Based on the reported behavior, the problem at the moment is that the .claims(claims)
method - which is called after using an .audience()
builder - treats the object as a Map<String,?>
, and just uses standard claim-to-value logic for each Map entry, and the standard behavior is to treat aud
as a JSON array per the finalized RFC.
In other words, the 'last call wins' as to the behavior seen.
Based on this it seems as if generic claim
, put
, putAll
logic should explicitly check for the aud
special case, and if a single string, delegate the .audience().single(String)
method instead of the simple map direct 'put'.
As you've indicated, there is a workaround for this for applications - just call the .audience()
builder after general claims are set, but I do understand how that's less desirable than it 'just working' regardless of method call order.
We'll use this ticket to track the work to implement this special case logic. Thank you for opening it!
from jjwt.
Related Issues (20)
- package jjwt is not resolved HOT 4
- Locator for Key has no access to JWT claims (issuer) HOT 1
- Error building JWT with non-string audience claim type HOT 4
- Disable Jackson ObjectMapper FAIL_ON_UNKNOWN_PROPERTIES Deserialization Feature HOT 1
- Unable to extract claims when cty specified in JWS header (>0.12.0) HOT 19
- Question: How far is version 1.0 (due to breaking changes in 0.12)?
- NIST Elliptic Curve JWK field element octet string padding HOT 1
- Allow parsing signed JWTs without the key HOT 1
- Impossible to build a JWK with `alg: HS512` and a `k` that is larger than 64 bytes HOT 2
- Make JacksonDeserializer constructor public
- Unable to access jcaName from Jwts.SIG HOT 2
- Jwts.builder - audience cannot be add without calling add() HOT 5
- Consider a convenience method to obtain a `Jwk` from a `JwkSet` by Key ID HOT 4
- Deprecation of support for unsecured JWT token parsing with algo != 'none' HOT 3
- NoSuchMethodError when using libraries built against older jjwt version HOT 2
- Unable to verify Elliptic Curve signature using configured ECPublicKey. Invalid encoding for signature HOT 2
- CVE reported against 0.11.5 HOT 5
- CVE-2024-31033 (v0.12.5) HOT 2
- java.lang.IllegalArgumentException: Invalid Map 'iv' (Initialization Vector) value: 1230868678. Values must be either String or [B instances. Value type found: java.math.BigInteger. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jjwt.