Skip to content
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

build(deps): bump io.jsonwebtoken:jjwt from 0.9.1 to 0.12.6 #499

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
<version>0.12.6</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ default void customize(QuerydslBindings bindings, QLogBatch root) {
")" +
" from LogBatch logBatch " +
"where logBatch.logDate >= :date " +
"group by function('to_char',logBatch.logDate,'YYYY-MM-DD') " +
"group by logBatch.logDate " +
// "group by function('to_char',logBatch.logDate,'YYYY-MM-DD') " +
"order by function('to_char',logBatch.logDate,'YYYY-MM-DD') desc")
List<StatisticByDayDto> countBatchByDay(@Param("date") Date date);

Expand Down
29 changes: 23 additions & 6 deletions src/main/java/fr/icdc/ebad/security/jwt/TokenProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.SignatureException;
import io.jsonwebtoken.UnsupportedJwtException;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
import jakarta.annotation.PostConstruct;
import org.bouncycastle.jcajce.provider.util.SecretKeyUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
Expand All @@ -18,7 +21,9 @@
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Component;

import javax.crypto.SecretKey;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.Date;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -69,16 +74,23 @@ public String createToken(Authentication authentication, Boolean rememberMe) {
return Jwts.builder()
.setSubject(authentication.getName())
.claim(AUTHORITIES_KEY, authorities)
.signWith(SignatureAlgorithm.HS512, secretKey)
.signWith(SignatureAlgorithm.HS512, Base64.getEncoder().encodeToString(secretKey.getBytes()))
.setExpiration(validity)
.compact();
}

public Authentication getAuthentication(String token) {
Claims claims = Jwts.parser()
.setSigningKey(secretKey)
.parseClaimsJws(token)
.getBody();
SecretKey secret = Keys.hmacShaKeyFor(secretKey.getBytes());
Claims claims =
Jwts.parser()
.verifyWith(secret)
.build()
.parseSignedClaims(token)
.getPayload();
// Jwts.parser()
// .setSigningKey(secretKey)
// .parseClaimsJws(token)
// .getBody();

Collection<? extends GrantedAuthority> authorities =
Arrays.stream(claims.get(AUTHORITIES_KEY).toString().split(","))
Expand All @@ -92,7 +104,12 @@ public Authentication getAuthentication(String token) {

public boolean validateToken(String authToken) {
try {
Jwts.parser().setSigningKey(secretKey).parseClaimsJws(authToken);
SecretKey secret = Keys.hmacShaKeyFor(secretKey.getBytes());
Jwts.parser()
.verifyWith(secret)
.build()
.parseSignedClaims(authToken)
.getPayload();
return true;
} catch (SignatureException e) {
log.info("Invalid JWT signature.");
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ ebad:
security:
authentication:
jwt:
secret: my-secret-token-to-change-in-production
secret: my-secret-token-to-change-in-production-my-secret-token-to-change-in-production
token-validity-in-seconds: 86400
token-validity-in-seconds-for-remember-me: 2592000
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
databaseChangeLog:
- changeSet:
id: 2.11.0-0-changeset
author: dtrouillet
changes:
- sql:
sql: update T_USER set PASSWORD = '$2y$10$MTbH9pg7B8zTpg9D1pMkb.cA2ZMAJwqMQwTdR9cDdRcAC4d6odjdy' where PASSWORD = '$2a$10$bPgTE7J0KkKC00Ep7i4w4.YhPgBklTDn1W4idlkv9tV5zcc1r54eq';
Loading