Skip to content

Commit bdebb3a

Browse files
committed
Upgrade JJWT to 0.12.6 and update JwtService for compatibility
1 parent c1f299b commit bdebb3a

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

server/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ dependencies {
9797

9898
runtimeOnly 'org.flywaydb:flyway-database-postgresql:11.8.1'
9999
runtimeOnly 'org.postgresql:postgresql:42.7.5'
100-
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.5'
101-
//implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
102-
//runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'
103-
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
104-
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
100+
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.6'
101+
implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
102+
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'
103+
//runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
104+
//implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
105105

106106
annotationProcessor 'org.projectlombok:lombok'
107107

server/src/main/java/dev/findfirst/security/jwt/JwtService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.findfirst.security.jwt;
22

33
import java.security.interfaces.RSAPrivateKey;
4+
import java.security.interfaces.RSAPublicKey;
45
import java.util.Map;
56

67
import jakarta.annotation.PostConstruct;
@@ -27,6 +28,8 @@ public class JwtService {
2728

2829
@Value("${jwt.private.key}")
2930
private RSAPrivateKey priv;
31+
@Value("${jwt.public.key}")
32+
private RSAPublicKey pubKey;
3033

3134
@Value("${findfirst.app.jwtCookieName}")
3235
private String jwtCookie;
@@ -37,7 +40,7 @@ public class JwtService {
3740

3841
@PostConstruct
3942
private void init() {
40-
jwtParser = Jwts.parserBuilder().setSigningKey(priv).build();
43+
jwtParser = Jwts.parser().verifyWith(pubKey).build();
4144
}
4245

4346
public String getJwtFromCookies(HttpServletRequest request) {
@@ -47,7 +50,7 @@ public String getJwtFromCookies(HttpServletRequest request) {
4750

4851
public Jws<Claims> parseJwt(String jwt) throws ExpiredJwtException, UnsupportedJwtException,
4952
MalformedJwtException, SignatureException, IllegalArgumentException {
50-
return jwtParser.parseClaimsJws(jwt);
53+
return jwtParser.parseSignedClaims(jwt);
5154
}
5255

5356
public String getUserNameFromJwtToken(String token) {

0 commit comments

Comments
 (0)