diff --git a/src/main/java/org/capstone/maru/config/SecurityConfig.java b/src/main/java/org/capstone/maru/config/SecurityConfig.java index af5d657ebf..eb8fcfdb54 100644 --- a/src/main/java/org/capstone/maru/config/SecurityConfig.java +++ b/src/main/java/org/capstone/maru/config/SecurityConfig.java @@ -2,8 +2,9 @@ import lombok.extern.slf4j.Slf4j; -import org.capstone.maru.dto.security.KakaoOAuth2Response; -import org.capstone.maru.dto.security.SharedPostPrincipal; +import org.capstone.maru.security.CustomOAuth2UserService; +import org.capstone.maru.security.KakaoOAuth2Response; +import org.capstone.maru.security.SharedPostPrincipal; import org.capstone.maru.service.MemberAccountService; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.security.servlet.PathRequest; @@ -28,15 +29,14 @@ public class SecurityConfig { @ConditionalOnProperty(name = "spring.h2.console.enabled", havingValue = "true") public WebSecurityCustomizer configureH2ConsoleEnable() { return web -> web.ignoring() - .requestMatchers(PathRequest.toH2Console()); + .requestMatchers(PathRequest.toH2Console()); } @Bean public SecurityFilterChain securityFilterChain( HttpSecurity httpSecurity, - OAuth2UserService oAuth2UserService + CustomOAuth2UserService customOAuth2UserService ) throws Exception { - log.info("SecurityFilterChain 빈 등록 완료"); return httpSecurity .authorizeHttpRequests(auth -> auth .requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll() @@ -48,7 +48,7 @@ public SecurityFilterChain securityFilterChain( ) .oauth2Login(oAuth -> oAuth .userInfoEndpoint(userInfo -> userInfo - .userService(oAuth2UserService) + .userService(customOAuth2UserService) ) ) .csrf( @@ -59,7 +59,6 @@ public SecurityFilterChain securityFilterChain( .build(); } - @Bean public OAuth2UserService oAuth2UserService( MemberAccountService memberAccountService, @@ -74,7 +73,7 @@ public OAuth2UserService oAuth2UserService( oAuth2User.getAttributes()); String registrationId = userRequest.getClientRegistration() - .getRegistrationId(); // "kakao" + .getRegistrationId(); // "kakao" String providerId = String.valueOf(kakaoOAuthResponse.id()); String memberId = registrationId + "_" + providerId; diff --git a/src/main/java/org/capstone/maru/controller/MainController.java b/src/main/java/org/capstone/maru/controller/MainController.java index 4c48fa81be..9568c0afc1 100644 --- a/src/main/java/org/capstone/maru/controller/MainController.java +++ b/src/main/java/org/capstone/maru/controller/MainController.java @@ -1,6 +1,6 @@ package org.capstone.maru.controller; -import org.capstone.maru.dto.security.SharedPostPrincipal; +import org.capstone.maru.security.SharedPostPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -17,5 +17,5 @@ public String root() { public String test(@AuthenticationPrincipal SharedPostPrincipal sharedPostPrincipal) { return sharedPostPrincipal.getName(); } - + }