fix: bug of auth config
This commit is contained in:
@@ -3,9 +3,11 @@ package org.fycd.bigdata.utils;
|
||||
import io.jsonwebtoken.*;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import io.jsonwebtoken.security.SignatureException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.fycd.bigdata.service.UserDetailsImpl;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
@@ -15,12 +17,11 @@ import java.util.Date;
|
||||
@Slf4j
|
||||
public class JwtUtils {
|
||||
@Value("${app.security.jwtSecret}")
|
||||
private static String jwtSecret;
|
||||
private String jwtSecret;
|
||||
|
||||
@Value("${app.security.jwtExpirationMs}")
|
||||
private static int jwtExpirationMs;
|
||||
private int jwtExpirationMs;
|
||||
|
||||
private static final byte[] secretKey = DatatypeConverter.parseBase64Binary(jwtSecret);
|
||||
|
||||
public String generateJwtToken(UserDetailsImpl userPrincipal) {
|
||||
return generateTokenFromUsername(userPrincipal.getUsername());
|
||||
@@ -52,6 +53,7 @@ public class JwtUtils {
|
||||
}
|
||||
|
||||
public String getUserNameFromJwtToken(String token) {
|
||||
byte[] secretKey = DatatypeConverter.parseBase64Binary(jwtSecret);
|
||||
return Jwts
|
||||
.parserBuilder()
|
||||
.setSigningKey(Keys.hmacShaKeyFor(secretKey))
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
app:
|
||||
security:
|
||||
jwtSecret: asdnkqldwk;l!@NLKASd12inkasldlxv.,xcvmkasldkqwe
|
||||
jwtExpirationMs: 86400000
|
||||
Reference in New Issue
Block a user