SecurityConfig.java 에서 AuthenticationManager 부분에 대한 질문입니다.
805
작성한 질문수 20
실전 프로젝트 보고 있습니다.
DB 연동 인증 처리(2) : CustomAuthenticationProvider 학습 중인데요.
스프링 버전이 2.7x 이라서 SecurityConfig.java 설정이 맞지를 않네요.
검색하니깐 아래 코드 처럼 설정하면 된다고 하던데 근데 아래 코드, authenticationManager 메서드 부분이 없어도 CustomAuthenticationProvider 클래스에 @Component 어노테이션 넣으니깐 사용되더라구요... 로그인도 잘되구요.
CustomUserDetailsService 클래스도 마찬가지인데, 아래 authenticationManager 메서드가 없어도 되는건지 궁금합니다.
혹시 나중에 문제가 생기지 않을까 불안하기도 하네요.
답변 부탁드리겠습니다.~
@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception {
ProviderManager authenticationManager = (ProviderManager) authenticationConfiguration.getAuthenticationManager();
authenticationManager.getProviders().add(customAuthenticationProvider());
return authenticationManager;
}
답변 1
1
네
CustomAuthenticationProvider 에 @Component 를 넣게 되면 스프링 시큐리티가 내부적으로 AuthenticationManager 가 관리하는 AuthenticationProvider 타입의 객체로 등록하게 됩니다.
그렇지만 CustomUserDetailsService 는 자동적으로 스프링 시큐리티가 참조할 수 있는 객체로 등록하거나 설정해 주지는 않습니다.
http.userdetailsService(CustomUserDetailsService) 와 같이 설정해 주어야 참조하게 됩니다
시큐리티 공부 버전 질문
0
175
1
[해결 방법] MethodSecurityConfig.customMethodSecurityMetadataSource() 호출하지 않는 이슈
0
186
1
AbstractSecurityInterceptor.class.beforeInvocation()를 2번 실행하는 경우
0
174
1
강의 코드가 왜이렇게 뒤죽박죽인가요...
0
249
1
메인 페이지로 접속해도 login url로 리다이렉트가 되지 않습니다..
0
236
1
파라미터값이 넘어가지 않습니다 ....
0
374
1
security filterChain 설정 질문이 있습니다.
0
332
1
소스 부분 질문 드립니다.
0
208
2
섹션4 7번 강의 문제가 있는거 같네요.
0
344
2
파일이 수시로 이름이 바껴있네요 ㄷㄷ
0
304
1
HttpSessionSecurityContextRepository를 사용안하는 문제
0
555
2
error , exception 이 잘 안됩니다.
0
282
2
thymeleaf tag 질문합니다.
0
196
2
버전업하면서 deprecated된 것들이 너무많아요
0
478
1
spring security 패치 관련
0
437
1
모바일을 사용할때 토큰말고 세션
0
846
2
DB 연동한 인가 부분에 대한 질문입니다!
0
264
1
Ajax방식도 똑같이 Session방식을 사용하는건가요?
0
307
1
Config 파일 생성 시 질문이 있습니다.
0
225
1
강사님 몇일동안 구글 검색만 100개 했는데도 이유를 모르겠습니다..
1
430
2
403 에러 뜹니다.
0
813
2
login_proc의 존재에 대한 간략한 설명입니다
0
276
1
top.html에 로그인 링크를 만들어서 로그인을 해봤습니다
0
283
2
안녕하세요. DB에 저장될 때 이해 안 가는 값이 있어서 질문드립니다!
0
189
1





