From c5c075dd07c47ac15ea9820600527e34ddc587bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:39:48 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat(SignController):=20=EC=84=BC=ED=84=B0?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Tag 일관성있도록 변경 --- .../center/controller/CenterSignController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/com/somemore/center/controller/CenterSignController.java diff --git a/src/main/java/com/somemore/center/controller/CenterSignController.java b/src/main/java/com/somemore/center/controller/CenterSignController.java new file mode 100644 index 000000000..59ab1db08 --- /dev/null +++ b/src/main/java/com/somemore/center/controller/CenterSignController.java @@ -0,0 +1,15 @@ +package com.somemore.center.controller; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Slf4j +@RequiredArgsConstructor +@RequestMapping("/api/center") +@Tag(name = "center Sign API", description = "기관 로그인, 로그아웃") +public class CenterSignController { +} From baff261b3b6c6d95e92e5e504829def2146eb681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:31:03 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat(SignOut):=20UseCase,=20Service?= =?UTF-8?q?=EB=A5=BC=20=EA=B8=B0=EA=B4=80=EC=97=90=EB=8F=84=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../signout/service/SignOutService.java} | 6 +++--- .../signout/usecase/SignOutUseCase.java} | 4 ++-- .../volunteer/controller/VolunteerSignController.java | 6 +++--- .../volunteer/service/SignOutVolunteerServiceTest.java | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) rename src/main/java/com/somemore/{volunteer/service/SignOutVolunteerService.java => auth/signout/service/SignOutService.java} (80%) rename src/main/java/com/somemore/{volunteer/usecase/SignOutVolunteerUseCase.java => auth/signout/usecase/SignOutUseCase.java} (59%) diff --git a/src/main/java/com/somemore/volunteer/service/SignOutVolunteerService.java b/src/main/java/com/somemore/auth/signout/service/SignOutService.java similarity index 80% rename from src/main/java/com/somemore/volunteer/service/SignOutVolunteerService.java rename to src/main/java/com/somemore/auth/signout/service/SignOutService.java index 95e015d0f..015377233 100644 --- a/src/main/java/com/somemore/volunteer/service/SignOutVolunteerService.java +++ b/src/main/java/com/somemore/auth/signout/service/SignOutService.java @@ -1,8 +1,8 @@ -package com.somemore.volunteer.service; +package com.somemore.auth.signout.service; import com.somemore.auth.cookie.CookieUseCase; import com.somemore.auth.jwt.refresh.manager.RefreshTokenManager; -import com.somemore.volunteer.usecase.SignOutVolunteerUseCase; +import com.somemore.auth.signout.usecase.SignOutUseCase; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -13,7 +13,7 @@ @Service @RequiredArgsConstructor @Transactional -public class SignOutVolunteerService implements SignOutVolunteerUseCase { +public class SignOutService implements SignOutUseCase { private final CookieUseCase cookieUseCase; private final RefreshTokenManager refreshTokenManager; diff --git a/src/main/java/com/somemore/volunteer/usecase/SignOutVolunteerUseCase.java b/src/main/java/com/somemore/auth/signout/usecase/SignOutUseCase.java similarity index 59% rename from src/main/java/com/somemore/volunteer/usecase/SignOutVolunteerUseCase.java rename to src/main/java/com/somemore/auth/signout/usecase/SignOutUseCase.java index b5a236ed6..6dcc4cc2d 100644 --- a/src/main/java/com/somemore/volunteer/usecase/SignOutVolunteerUseCase.java +++ b/src/main/java/com/somemore/auth/signout/usecase/SignOutUseCase.java @@ -1,8 +1,8 @@ -package com.somemore.volunteer.usecase; +package com.somemore.auth.signout.usecase; import jakarta.servlet.http.HttpServletResponse; -public interface SignOutVolunteerUseCase { +public interface SignOutUseCase { void signOut(HttpServletResponse response, String volunteerId); } diff --git a/src/main/java/com/somemore/volunteer/controller/VolunteerSignController.java b/src/main/java/com/somemore/volunteer/controller/VolunteerSignController.java index 54e982203..54255ebcf 100644 --- a/src/main/java/com/somemore/volunteer/controller/VolunteerSignController.java +++ b/src/main/java/com/somemore/volunteer/controller/VolunteerSignController.java @@ -2,7 +2,7 @@ import com.somemore.global.common.response.ApiResponse; import com.somemore.global.exception.BadRequestException; -import com.somemore.volunteer.usecase.SignOutVolunteerUseCase; +import com.somemore.auth.signout.usecase.SignOutUseCase; import com.somemore.volunteer.usecase.GenerateOAuthUrlUseCase; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; @@ -25,7 +25,7 @@ public class VolunteerSignController { private final GenerateOAuthUrlUseCase generateOAuthUrlUseCase; - private final SignOutVolunteerUseCase signOutVolunteerUseCase; + private final SignOutUseCase signOutUseCase; @PostMapping("/sign-in/oauth/{oauthProvider}") public RedirectView signIn( @@ -46,7 +46,7 @@ public ApiResponse signOut( HttpServletResponse response, @AuthenticationPrincipal String userId) { - signOutVolunteerUseCase.signOut(response, userId); + signOutUseCase.signOut(response, userId); return ApiResponse.ok("로그아웃되었습니다"); } diff --git a/src/test/java/com/somemore/volunteer/service/SignOutVolunteerServiceTest.java b/src/test/java/com/somemore/volunteer/service/SignOutVolunteerServiceTest.java index e88c6b5cc..98e883ac3 100644 --- a/src/test/java/com/somemore/volunteer/service/SignOutVolunteerServiceTest.java +++ b/src/test/java/com/somemore/volunteer/service/SignOutVolunteerServiceTest.java @@ -10,6 +10,7 @@ import com.somemore.auth.jwt.generator.JwtGenerator; import com.somemore.auth.jwt.refresh.domain.RefreshToken; import com.somemore.auth.jwt.refresh.manager.RefreshTokenManager; +import com.somemore.auth.signout.service.SignOutService; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -25,7 +26,7 @@ class SignOutVolunteerServiceTest extends IntegrationTestSupport { @Autowired - private SignOutVolunteerService signOutVolunteerService; + private SignOutService signOutVolunteerService; @Autowired private CookieUseCase cookieUseCase; @Autowired From ed5408c1565ec06b8f8bacdc841ef83b81bc04ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:31:42 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat(CenterSignOut):=20=EA=B8=B0=EA=B4=80?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=95=84=EC=9B=83=20=EC=97=94=EB=93=9C?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CenterSignController.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/somemore/center/controller/CenterSignController.java b/src/main/java/com/somemore/center/controller/CenterSignController.java index 59ab1db08..eb022c121 100644 --- a/src/main/java/com/somemore/center/controller/CenterSignController.java +++ b/src/main/java/com/somemore/center/controller/CenterSignController.java @@ -1,8 +1,13 @@ package com.somemore.center.controller; +import com.somemore.auth.signout.usecase.SignOutUseCase; +import com.somemore.global.common.response.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -10,6 +15,18 @@ @Slf4j @RequiredArgsConstructor @RequestMapping("/api/center") -@Tag(name = "center Sign API", description = "기관 로그인, 로그아웃") +@Tag(name = "center Sign API", description = "기관 로그아웃") public class CenterSignController { + + private final SignOutUseCase signOutUseCase; + + @PostMapping("/sign-out") + public ApiResponse signOut( + HttpServletResponse response, + @AuthenticationPrincipal String userId) { + + signOutUseCase.signOut(response, userId); + + return ApiResponse.ok("로그아웃되었습니다"); + } } From b9eddaf5d4aa795f040dd60841934a06d0fb68d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:32:04 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat(CORS):=205173=20=ED=8F=AC=ED=8A=B8=20(?= =?UTF-8?q?Vite)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/somemore/global/configure/WebConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/somemore/global/configure/WebConfig.java b/src/main/java/com/somemore/global/configure/WebConfig.java index aac9dfdcf..6f11baadd 100644 --- a/src/main/java/com/somemore/global/configure/WebConfig.java +++ b/src/main/java/com/somemore/global/configure/WebConfig.java @@ -12,6 +12,7 @@ public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins( "http://localhost:3000", + "http://localhost:5173", "http://front-deploy.s3-website.ap-northeast-2.amazonaws.com" ) .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") From af52d5d8c165e24f67326b1ce5528874f5d4ef6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:40:30 +0900 Subject: [PATCH 5/6] =?UTF-8?q?feat(OAuthFailureHandler):=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/oauth/handler/failure/CustomOAuthFailureHandler.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/somemore/auth/oauth/handler/failure/CustomOAuthFailureHandler.java b/src/main/java/com/somemore/auth/oauth/handler/failure/CustomOAuthFailureHandler.java index d7ba81196..6c76852bc 100644 --- a/src/main/java/com/somemore/auth/oauth/handler/failure/CustomOAuthFailureHandler.java +++ b/src/main/java/com/somemore/auth/oauth/handler/failure/CustomOAuthFailureHandler.java @@ -17,5 +17,7 @@ public class CustomOAuthFailureHandler extends SimpleUrlAuthenticationFailureHan public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) { // TODO 프론트엔드와 협의 log.error("안녕 난 말하는 감자야"); + log.error(exception.getMessage()); + log.error(exception.getCause().getMessage()); } } From dd922b482d69be726d76e188cacc3711dabe66aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:42:02 +0900 Subject: [PATCH 6/6] =?UTF-8?q?feat(SignOut):=20ApiResponse=20data=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/somemore/center/controller/CenterSignController.java | 2 +- .../somemore/volunteer/controller/VolunteerSignController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/somemore/center/controller/CenterSignController.java b/src/main/java/com/somemore/center/controller/CenterSignController.java index eb022c121..f4a3c781d 100644 --- a/src/main/java/com/somemore/center/controller/CenterSignController.java +++ b/src/main/java/com/somemore/center/controller/CenterSignController.java @@ -21,7 +21,7 @@ public class CenterSignController { private final SignOutUseCase signOutUseCase; @PostMapping("/sign-out") - public ApiResponse signOut( + public ApiResponse signOut( HttpServletResponse response, @AuthenticationPrincipal String userId) { diff --git a/src/main/java/com/somemore/volunteer/controller/VolunteerSignController.java b/src/main/java/com/somemore/volunteer/controller/VolunteerSignController.java index 54255ebcf..e6f93fcdf 100644 --- a/src/main/java/com/somemore/volunteer/controller/VolunteerSignController.java +++ b/src/main/java/com/somemore/volunteer/controller/VolunteerSignController.java @@ -42,7 +42,7 @@ public RedirectView signIn( } @PostMapping("/sign-out") - public ApiResponse signOut( + public ApiResponse signOut( HttpServletResponse response, @AuthenticationPrincipal String userId) {