From 38bbe455b4a3e7aa5edd0de16fe7796667068a28 Mon Sep 17 00:00:00 2001 From: Hyeonjun Park <55674648+phjppo0918@users.noreply.github.com> Date: Thu, 20 Jul 2023 19:33:18 +0900 Subject: [PATCH] =?UTF-8?q?jwt=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EA=B4=80=EB=A0=A8=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=9C=20Controller=20Advice=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20jwt=20config=EC=8B=9C=20?= =?UTF-8?q?=EC=9D=BC=EB=B6=80=20=EA=B0=92=20default=20value=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20#PAR-194=20(#11)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat : Controller advice 삭제 및 jwt manager default value 설정 * style : Google Java Format * fix : refresh secret key default value 적용 안되는 현상 수정 * style : Google Java Format * fix : expire second default value 적용 안되는 현상 수정 * style : Google Java Format --------- Co-authored-by: github-actions <> --- .../partyrun/jwtmanager/config/JwtConfig.java | 8 ++++--- .../controller/ExceptionResponse.java | 3 --- .../controller/JwtControllerAdvice.java | 23 ------------------- ...ot.autoconfigure.AutoConfiguration.imports | 3 +-- 4 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 src/main/java/online/partyrun/jwtmanager/controller/ExceptionResponse.java delete mode 100644 src/main/java/online/partyrun/jwtmanager/controller/JwtControllerAdvice.java diff --git a/src/main/java/online/partyrun/jwtmanager/config/JwtConfig.java b/src/main/java/online/partyrun/jwtmanager/config/JwtConfig.java index b295b12..de72d48 100644 --- a/src/main/java/online/partyrun/jwtmanager/config/JwtConfig.java +++ b/src/main/java/online/partyrun/jwtmanager/config/JwtConfig.java @@ -21,9 +21,11 @@ public class JwtConfig { @Bean public JwtManager jwtManager( @Value("${jwt.access-secret-key}") String accessKey, - @Value("${jwt.access-expire-second}") Long accessExpireSecond, - @Value("${jwt.refresh-secret-key}") String refreshKey, - @Value("${jwt.refresh-expire-second}") Long refreshExpireSecond) { + @Value("${jwt.access-expire-second:#{'1'}}") Long accessExpireSecond, + @Value( + "${jwt.refresh-secret-key:#{'DefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefaultDefault'}}") + String refreshKey, + @Value("${jwt.refresh-expire-second:#{'1'}}") Long refreshExpireSecond) { log.info("Starting JwtManager"); return new JwtManager( tokenManager(accessKey, accessExpireSecond), diff --git a/src/main/java/online/partyrun/jwtmanager/controller/ExceptionResponse.java b/src/main/java/online/partyrun/jwtmanager/controller/ExceptionResponse.java deleted file mode 100644 index cbbac39..0000000 --- a/src/main/java/online/partyrun/jwtmanager/controller/ExceptionResponse.java +++ /dev/null @@ -1,3 +0,0 @@ -package online.partyrun.jwtmanager.controller; - -public record ExceptionResponse(String message) {} diff --git a/src/main/java/online/partyrun/jwtmanager/controller/JwtControllerAdvice.java b/src/main/java/online/partyrun/jwtmanager/controller/JwtControllerAdvice.java deleted file mode 100644 index ae26003..0000000 --- a/src/main/java/online/partyrun/jwtmanager/controller/JwtControllerAdvice.java +++ /dev/null @@ -1,23 +0,0 @@ -package online.partyrun.jwtmanager.controller; - -import io.jsonwebtoken.JwtException; - -import lombok.extern.slf4j.Slf4j; - -import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -@Slf4j -@AutoConfiguration -@RestControllerAdvice(basePackages = "online.partyrun.jwtmanager") -public class JwtControllerAdvice { - @ExceptionHandler({JwtException.class, IllegalArgumentException.class}) - @ResponseStatus(HttpStatus.UNAUTHORIZED) - public ExceptionResponse handleJwtException(RuntimeException exception) { - log.error("{}", exception.getMessage()); - return new ExceptionResponse("승인되지 않은 요청입니다."); - } -} diff --git a/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 44e424d..fc54634 100644 --- a/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,2 +1 @@ -online.partyrun.jwtmanager.config.JwtConfig -online.partyrun.jwtmanager.controller.JwtControllerAdvice \ No newline at end of file +online.partyrun.jwtmanager.config.JwtConfig \ No newline at end of file