-
[오류 기록] Custom WebSecurityConfigurerAdapter가 적용되지 않음Spring 2022. 6. 26. 07:32
문제
WebSecurityConfigurerAdapter을 상속받은 SecurityConfig 클래스에서 configure 메서드를 오버라이딩하여 인증을 선택적으로 적용하였다.
"/" 은 permitAll을 적용한 url중 하나인데 /페이지에 접속하면 인증을 요구하였다.
원인
SecurityConfig 클래스가 포함된 oauth2 패키지가 @SpringBootApplication을 포함하고 있는 DeveloperCommunityApplication.kt 파일을 포함하는 프로젝트 패키지에 포함되어 있지 않았다.
따라서 ComponentScan의 적용 대상이 되지 않았다.
시도한 해결방법
oauth2 패키지를 developercommunity 패키지(프로젝트 패키지) 하위로 옮겼다.
(애초에 왜 밖에다 만들었는지 모르겠음. 실수인 것 같다)
해결 여부
해결 완료
Reference
Custom security is not working when extending the WebSecurityConfigurerAdapter class in different package
I have extendend WebSecurityConfigurerAdapter in a different package other than the package containing class for @SpringBootApplication. Then it's not working its generating default username and pa...
stackoverflow.com
'Spring' 카테고리의 다른 글
[Spring][Kotlin] 빈 스코프 (0) 2022.05.21 [Spring][Kotlin] 빈 생명주기 콜백 (0) 2022.05.21 [Spring][Kotlin]의존관계 자동 주입 (0) 2022.05.21 [Spring][Kotlin]컴포넌트 스캔 (0) 2022.05.19 [Spring][Kotlin] 싱글톤 컨테이너 (0) 2022.05.18