From 524ac811bf6aa60dd61e78b159f3d609ea23cb63 Mon Sep 17 00:00:00 2001 From: rlarltj123 Date: Fri, 26 Jul 2024 00:19:37 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EB=94=94=EB=B2=84=EA=B9=85=EC=9D=84?= =?UTF-8?q?=20=EC=9C=84=ED=95=9C=20=EB=A1=9C=EA=B7=B8=EB=A5=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moneymong/domain/user/service/UserFacadeService.java | 8 ++++++++ .../moneymong/global/config/security/SecurityConfig.java | 1 + .../global/security/oauth/dto/OAuthUserDataRequest.java | 2 ++ .../global/security/oauth/dto/OAuthUserInfo.java | 1 + .../moneymong/global/security/service/OAuthService.java | 5 ++++- .../com/moneymong/global/security/token/dto/Tokens.java | 2 ++ 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/moneymong/domain/user/service/UserFacadeService.java b/src/main/java/com/moneymong/domain/user/service/UserFacadeService.java index 885d6f7..853d06d 100644 --- a/src/main/java/com/moneymong/domain/user/service/UserFacadeService.java +++ b/src/main/java/com/moneymong/domain/user/service/UserFacadeService.java @@ -10,10 +10,13 @@ import com.moneymong.global.security.token.dto.Tokens; import com.moneymong.global.security.token.service.TokenService; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service +@Slf4j @RequiredArgsConstructor public class UserFacadeService { private final UserService userService; @@ -25,12 +28,17 @@ public class UserFacadeService { public LoginSuccessResponse login(LoginRequest loginRequest) { OAuthUserDataResponse oAuthUserData = oAuthService.login(loginRequest); + log.info("Token = {}", loginRequest.getAccessToken()); + log.info("Code = {}", loginRequest.getCode()); + OAuthUserInfo oAuthUserInfo = OAuthUserInfo.from(oAuthUserData); + log.info("OAuthUserInfo = {}", oAuthUserInfo); AuthUserInfo registerResult = userService.getOrRegister(oAuthUserInfo); Tokens tokens = tokenService.createTokens(registerResult); + log.info("TOKENS = {}", tokens); boolean loginSuccess = true; boolean schoolInfoExists = userUniversityService.exists(registerResult.getUserId()); diff --git a/src/main/java/com/moneymong/global/config/security/SecurityConfig.java b/src/main/java/com/moneymong/global/config/security/SecurityConfig.java index 9c22ac3..759a99a 100644 --- a/src/main/java/com/moneymong/global/config/security/SecurityConfig.java +++ b/src/main/java/com/moneymong/global/config/security/SecurityConfig.java @@ -37,6 +37,7 @@ public SecurityFilterChain httpSecurity(HttpSecurity http) throws Exception { auth.requestMatchers("/api/v1/users").permitAll(); auth.requestMatchers("/api/v1/tokens").permitAll(); auth.requestMatchers("/actuator/**").permitAll(); + auth.anyRequest().authenticated(); }) .exceptionHandling(handler -> handler.authenticationEntryPoint(jwtAuthenticationEntryPoint)) .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) diff --git a/src/main/java/com/moneymong/global/security/oauth/dto/OAuthUserDataRequest.java b/src/main/java/com/moneymong/global/security/oauth/dto/OAuthUserDataRequest.java index e9265e6..0cca58b 100644 --- a/src/main/java/com/moneymong/global/security/oauth/dto/OAuthUserDataRequest.java +++ b/src/main/java/com/moneymong/global/security/oauth/dto/OAuthUserDataRequest.java @@ -2,8 +2,10 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.ToString; @Getter +@ToString @AllArgsConstructor public class OAuthUserDataRequest { private String accessToken; diff --git a/src/main/java/com/moneymong/global/security/oauth/dto/OAuthUserInfo.java b/src/main/java/com/moneymong/global/security/oauth/dto/OAuthUserInfo.java index 7468856..10c6352 100644 --- a/src/main/java/com/moneymong/global/security/oauth/dto/OAuthUserInfo.java +++ b/src/main/java/com/moneymong/global/security/oauth/dto/OAuthUserInfo.java @@ -6,6 +6,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor +@ToString public class OAuthUserInfo { private String provider; private String oauthId; diff --git a/src/main/java/com/moneymong/global/security/service/OAuthService.java b/src/main/java/com/moneymong/global/security/service/OAuthService.java index 11a0cf5..691231c 100644 --- a/src/main/java/com/moneymong/global/security/service/OAuthService.java +++ b/src/main/java/com/moneymong/global/security/service/OAuthService.java @@ -18,7 +18,10 @@ import static com.moneymong.global.exception.enums.ErrorCode.USER_NOT_FOUND; +import lombok.extern.slf4j.Slf4j; + @Service +@Slf4j public class OAuthService { private final Map oAuthAuthenticationHandlers; @@ -41,7 +44,7 @@ public OAuthUserDataResponse login(LoginRequest loginRequest) { loginRequest.getCode(), loginRequest.getName() ); - + log.info("[OAuthService OAuthUserDataRequest] = {}", request); return oAuthHandler.getOAuthUserData(request); } diff --git a/src/main/java/com/moneymong/global/security/token/dto/Tokens.java b/src/main/java/com/moneymong/global/security/token/dto/Tokens.java index 23ddc0b..b34cade 100644 --- a/src/main/java/com/moneymong/global/security/token/dto/Tokens.java +++ b/src/main/java/com/moneymong/global/security/token/dto/Tokens.java @@ -2,8 +2,10 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.ToString; @Getter +@ToString @AllArgsConstructor public class Tokens { private final String accessToken;