Skip to content

Commit

Permalink
build(deps): bump io.jsonwebtoken:jjwt from 0.9.1 to 0.12.6 (#499)
Browse files Browse the repository at this point in the history
* build(deps): bump io.jsonwebtoken:jjwt from 0.9.1 to 0.12.6

Bumps [io.jsonwebtoken:jjwt](https://github.com/jwtk/jjwt) from 0.9.1 to 0.12.6.
- [Release notes](https://github.com/jwtk/jjwt/releases)
- [Changelog](https://github.com/jwtk/jjwt/blob/master/CHANGELOG.md)
- [Commits](jwtk/jjwt@0.9.1...0.12.6)

---
updated-dependencies:
- dependency-name: io.jsonwebtoken:jjwt
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix(): fix spring data

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Damien Trouillet <[email protected]>
Co-authored-by: Damien Trouillet <[email protected]>
  • Loading branch information
3 people authored Aug 1, 2024
1 parent 59ea2bc commit ea7a39e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
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';

0 comments on commit ea7a39e

Please sign in to comment.