diff --git a/src/main/java/com/moabam/api/application/AuthorizationService.java b/src/main/java/com/moabam/api/application/AuthorizationService.java index b8955bf1..8f2db0e3 100644 --- a/src/main/java/com/moabam/api/application/AuthorizationService.java +++ b/src/main/java/com/moabam/api/application/AuthorizationService.java @@ -121,8 +121,7 @@ private MultiValueMap generateTokenRequest(AuthorizationTokenReq public void issueServiceToken(HttpServletResponse response, PublicClaim publicClaim) { response.addCookie( - CookieUtils.typeCookie("token_type", "Bearer", - tokenConfig.getRefreshExpire())); + CookieUtils.typeCookie("Bearer", tokenConfig.getRefreshExpire())); response.addCookie( CookieUtils.tokenCookie("access_token", jwtProviderService.provideAccessToken(publicClaim), tokenConfig.getRefreshExpire())); diff --git a/src/main/java/com/moabam/global/common/util/PathResolver.java b/src/main/java/com/moabam/global/common/handler/PathResolver.java similarity index 98% rename from src/main/java/com/moabam/global/common/util/PathResolver.java rename to src/main/java/com/moabam/global/common/handler/PathResolver.java index aad67b66..76ab8cb4 100644 --- a/src/main/java/com/moabam/global/common/util/PathResolver.java +++ b/src/main/java/com/moabam/global/common/handler/PathResolver.java @@ -1,4 +1,4 @@ -package com.moabam.global.common.util; +package com.moabam.global.common.handler; import static java.util.Objects.*; diff --git a/src/main/java/com/moabam/global/common/util/CookieUtils.java b/src/main/java/com/moabam/global/common/util/CookieUtils.java index 4f1aa490..c1220718 100644 --- a/src/main/java/com/moabam/global/common/util/CookieUtils.java +++ b/src/main/java/com/moabam/global/common/util/CookieUtils.java @@ -8,25 +8,20 @@ public class CookieUtils { public static Cookie tokenCookie(String name, String value, long expireTime) { - Cookie cookie = new Cookie(name, value); - basic(cookie, expireTime); - secure(cookie); - return cookie; + return basic(name, value, expireTime); } - public static Cookie typeCookie(String name, String value, long expireTime) { - Cookie cookie = new Cookie(name, value); - basic(cookie, expireTime); - return cookie; + public static Cookie typeCookie(String value, long expireTime) { + return basic("token_type", value, expireTime); } - private static void secure(Cookie cookie) { + private static Cookie basic(String name, String value, long expireTime) { + Cookie cookie = new Cookie(name, value); cookie.setSecure(true); - } - - private static void basic(Cookie cookie, long expireTime) { cookie.setHttpOnly(true); cookie.setPath("/"); cookie.setMaxAge((int)expireTime); + + return cookie; } } diff --git a/src/main/java/com/moabam/global/config/WebConfig.java b/src/main/java/com/moabam/global/config/WebConfig.java index b6adb686..a02359a1 100644 --- a/src/main/java/com/moabam/global/config/WebConfig.java +++ b/src/main/java/com/moabam/global/config/WebConfig.java @@ -9,7 +9,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.moabam.global.common.handler.CurrentMemberArgumentResolver; -import com.moabam.global.common.util.PathResolver; +import com.moabam.global.common.handler.PathResolver; @Configuration public class WebConfig implements WebMvcConfigurer { diff --git a/src/main/java/com/moabam/global/filter/PathFilter.java b/src/main/java/com/moabam/global/filter/PathFilter.java index ab4fe302..4baf8aa9 100644 --- a/src/main/java/com/moabam/global/filter/PathFilter.java +++ b/src/main/java/com/moabam/global/filter/PathFilter.java @@ -7,7 +7,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; -import com.moabam.global.common.util.PathResolver; +import com.moabam.global.common.handler.PathResolver; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; diff --git a/src/test/java/com/moabam/global/common/util/PathResolverTest.java b/src/test/java/com/moabam/global/common/handler/PathResolverTest.java similarity index 94% rename from src/test/java/com/moabam/global/common/util/PathResolverTest.java rename to src/test/java/com/moabam/global/common/handler/PathResolverTest.java index aac9a048..f77cd436 100644 --- a/src/test/java/com/moabam/global/common/util/PathResolverTest.java +++ b/src/test/java/com/moabam/global/common/handler/PathResolverTest.java @@ -1,4 +1,4 @@ -package com.moabam.global.common.util; +package com.moabam.global.common.handler; import static com.moabam.api.domain.entity.enums.Role.*; import static org.assertj.core.api.Assertions.*; @@ -10,6 +10,8 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import com.moabam.global.common.handler.PathResolver; + class PathResolverTest { @DisplayName("path 기본 생성 성공") diff --git a/src/test/java/com/moabam/global/filter/PathFilterTest.java b/src/test/java/com/moabam/global/filter/PathFilterTest.java index 718575b7..3429bb0a 100644 --- a/src/test/java/com/moabam/global/filter/PathFilterTest.java +++ b/src/test/java/com/moabam/global/filter/PathFilterTest.java @@ -19,7 +19,7 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; -import com.moabam.global.common.util.PathResolver; +import com.moabam.global.common.handler.PathResolver; import jakarta.servlet.ServletException; diff --git a/src/test/java/com/moabam/support/common/WithFilterSupporter.java b/src/test/java/com/moabam/support/common/WithFilterSupporter.java index 1ca7a542..c5e198ca 100644 --- a/src/test/java/com/moabam/support/common/WithFilterSupporter.java +++ b/src/test/java/com/moabam/support/common/WithFilterSupporter.java @@ -39,11 +39,11 @@ void setUpMockMvc(RestDocumentationContextProvider contextProvider) { mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) .apply(RestDocsFactory.restdocs(contextProvider)) .defaultRequest(get("/") - .cookie(CookieUtils.typeCookie("token_type", "Bearer", tokenConfig.getRefreshExpire())) - .cookie(CookieUtils.typeCookie("access_token", + .cookie(CookieUtils.typeCookie("Bearer", tokenConfig.getRefreshExpire())) + .cookie(CookieUtils.tokenCookie("access_token", jwtProviderService.provideAccessToken(PublicClaimFixture.publicClaim()), tokenConfig.getRefreshExpire())) - .cookie(CookieUtils.typeCookie("refresh_token", + .cookie(CookieUtils.tokenCookie("refresh_token", jwtProviderService.provideRefreshToken(), tokenConfig.getRefreshExpire()))) .build(); diff --git a/src/test/java/com/moabam/support/common/WithoutFilterSupporter.java b/src/test/java/com/moabam/support/common/WithoutFilterSupporter.java index 4381cbd6..189e6536 100644 --- a/src/test/java/com/moabam/support/common/WithoutFilterSupporter.java +++ b/src/test/java/com/moabam/support/common/WithoutFilterSupporter.java @@ -12,7 +12,7 @@ import com.moabam.api.application.AuthorizationService; import com.moabam.api.application.JwtAuthenticationService; import com.moabam.api.domain.entity.enums.Role; -import com.moabam.global.common.util.PathResolver; +import com.moabam.global.common.handler.PathResolver; @ExtendWith({FilterProcessExtension.class}) public class WithoutFilterSupporter {