Skip to content

Commit

Permalink
Add de-serializer configuration so that you can de-serialize this w/ …
Browse files Browse the repository at this point in the history
…any Jackson ObjectMapper w/out having to register the handlers yourself.
  • Loading branch information
robotdan committed May 30, 2023
1 parent 4a7eafb commit b042821
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ build
*.iws
.idea
target
.DS_Store
.DS_Store
.savant/cache
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FusionAuth JWT Changes

Changes in 5.2.4

* Bind a deserializer using @JsonDeserialize the JWT object for all ZoneDateTime objects. This allows
you to use any Jackson Object Mapper w/out explicitly binding these deserializers.

Changes in 5.2.3

* Upgraded Jackson Core to 2.14.0
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ We are very interested in compensating anyone that can identify a security relat
<dependency>
<groupId>io.fusionauth</groupId>
<artifactId>fusionauth-jwt</artifactId>
<version>5.2.3</version>
<version>5.2.4</version>
</dependency>
```

### Gradle
```groovy
implementation 'io.fusionauth:fusionauth-jwt:5.2.3'
implementation 'io.fusionauth:fusionauth-jwt:5.2.4'
```

### Gradle Kotlin
```kotlin
implementation("io.fusionauth:fusionauth-jwt:5.2.3")
implementation("io.fusionauth:fusionauth-jwt:5.2.4")
```

### Savant
```groovy
dependency(id: "io.fusionauth:fusionauth-jwt:5.2.3")
dependency(id: "io.fusionauth:fusionauth-jwt:5.2.4")
```

For others see [https://search.maven.org](https://search.maven.org/artifact/io.fusionauth/fusionauth-jwt/4.0.1/jar).
Expand Down
2 changes: 1 addition & 1 deletion build.savant
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

jacksonVersion = "2.14.0"

project(group: "io.fusionauth", name: "fusionauth-jwt", version: "5.2.3", licenses: ["ApacheV2_0"]) {
project(group: "io.fusionauth", name: "fusionauth-jwt", version: "5.2.4", licenses: ["ApacheV2_0"]) {

workflow {
fetch {
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/io/fusionauth/jwt/domain/JWT.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2022, FusionAuth, All Rights Reserved
* Copyright (c) 2016-2023, FusionAuth, All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,11 +20,13 @@
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.fusionauth.jwt.JWTDecoder;
import io.fusionauth.jwt.JWTEncoder;
import io.fusionauth.jwt.TimeMachineJWTDecoder;
import io.fusionauth.jwt.json.Mapper;
import io.fusionauth.jwt.json.ZonedDateTimeDeserializer;
import io.fusionauth.jwt.json.ZonedDateTimeSerializer;

import java.math.BigDecimal;
Expand Down Expand Up @@ -71,6 +73,7 @@ public class JWT {
* processing. The expiration time is expected to provided in UNIX time, or the number of seconds since Epoch.
*/
@JsonProperty("exp")
@JsonDeserialize(using = ZonedDateTimeDeserializer.class)
@JsonSerialize(using = ZonedDateTimeSerializer.class)
public ZonedDateTime expiration;

Expand All @@ -81,6 +84,7 @@ public class JWT {
* UNIX time, or the number of seconds since Epoch.
*/
@JsonProperty("iat")
@JsonDeserialize(using = ZonedDateTimeDeserializer.class)
@JsonSerialize(using = ZonedDateTimeSerializer.class)
public ZonedDateTime issuedAt;

Expand All @@ -97,9 +101,10 @@ public class JWT {
* Registered Claim <code>nbf</code> as defined by RFC 7519 Section 4.1.5. Use of this claim is OPTIONAL.
* <p>
* This claim identifies the time before which the JWT MUST NOT be accepted for processing. The not before value is
* expected to provided in UNIX time, or the number of seconds since Epoch.
* expected to be provided in UNIX time, or the number of seconds since Epoch.
*/
@JsonProperty("nbf")
@JsonDeserialize(using = ZonedDateTimeDeserializer.class)
@JsonSerialize(using = ZonedDateTimeSerializer.class)
public ZonedDateTime notBefore;

Expand Down

0 comments on commit b042821

Please sign in to comment.