From 414e677763f017ae01dbc588d2c86c470e47287b Mon Sep 17 00:00:00 2001 From: Lucas Saldanha Date: Fri, 6 Oct 2023 09:06:44 +1300 Subject: [PATCH] Explicit jackson serializer for jwt token provider --- ethereum/executionclient/build.gradle | 2 +- .../teku/ethereum/executionclient/auth/TokenProvider.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ethereum/executionclient/build.gradle b/ethereum/executionclient/build.gradle index e22e3df984b..f66f6670b86 100644 --- a/ethereum/executionclient/build.gradle +++ b/ethereum/executionclient/build.gradle @@ -16,7 +16,7 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-api' runtimeOnly 'io.jsonwebtoken:jjwt-impl' - runtimeOnly 'io.jsonwebtoken:jjwt-jackson' + implementation 'io.jsonwebtoken:jjwt-jackson' testImplementation testFixtures(project(':infrastructure:async')) testImplementation testFixtures(project(':infrastructure:time')) diff --git a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/auth/TokenProvider.java b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/auth/TokenProvider.java index ef3f744a860..01af8e4c46d 100644 --- a/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/auth/TokenProvider.java +++ b/ethereum/executionclient/src/main/java/tech/pegasys/teku/ethereum/executionclient/auth/TokenProvider.java @@ -15,6 +15,7 @@ import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; +import io.jsonwebtoken.jackson.io.JacksonSerializer; import java.time.Instant; import java.util.Date; import java.util.Optional; @@ -35,6 +36,7 @@ public Optional token(final UInt64 instantInMillis) { Jwts.builder() .setIssuedAt(Date.from(Instant.ofEpochMilli(instantInMillis.longValue()))) .signWith(jwtConfig.getKey(), SignatureAlgorithm.HS256) + .serializeToJsonWith(new JacksonSerializer<>()) .compact(); return Optional.of(new Token(jwtToken, expiry)); }