-
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
Include auth_time in SpecDates #825
Comments
FWIW, jjwt/impl/src/main/java/io/jsonwebtoken/impl/DefaultClaims.java Lines 43 to 45 in b55f261
(The name This is mostly a reflection that the JJWT team implements support for all standards defined by the JOSE Working Group (which are 9 RFCs at the time of writing).
The reasons for this are a few:
That said, I would like to support all of these where feasible, but I don't know what that looks like just yet - i.e. should the In any event, this level of non-JOSE-spec parameters will have to wait until probably after 1.0. So your approach of getting a Finally, thank you once again for a well-written / formatted issue - it really helps! |
Also, just writing my thoughts for posterity: An ideal place for this JSON-to-Object unmarshalling behavior would likely be done via the the underlying JSON processor (Jackson, GSON, etc) since those libraries are purpose-built for JSON-to-Java-Instance conversion logic (well, except For example, Jackson and GSON can take any field and unmarshall it into whatever Java object type you prefer before JJWT ever gets the Instant authTime = claims.get("auth_time", Instant.class); We (JJWT) don't really want to be in the business of JSON-to-Java unmarshalling when other libraries are wholly dedicated to this concept. That is, we don't want to 'reinvent the wheel' and we'd rather 'stand on the shoulders of giants' for this type of functionality if we can. |
Is your feature request related to a problem? Please describe.
"auth_time" is not part of the default fields in
Claims
. When we need to read it, we cannot useclaims.get("auth_time", Date.class)
because the parameter is in seconds and java.util.Date requires milliseconds.Describe the solution you'd like
Ideally all the Authentication Information Claims (
auth_time
,acr
,amr
) added as getters inClaims
, or justauth_time
added inDefaultClaims.isSpecDate
, to be able to do e.g.claims.get("auth_time", Date.class)
.Describe alternatives you've considered
Instead of reading it as a Date directly, we need to do something like:
var authTimeSeconds = claims.get("auth_time", Long.class);
var authTime = authTimeSeconds == null ? null : new Date(authTimeSeconds * 1000);
Additional context
See https://datatracker.ietf.org/doc/html/rfc9068#section-2.2.1
The text was updated successfully, but these errors were encountered: