스프링 시큐리티 문의 (webSecurityConfigurerAdapter 취소선)
1840
6 asked
안녕하세요. 스프링시큐리티 로그인관련 진행하다가 extends webSecurityConfigurerAdapter 가 취소선이 나와서 확인해보니 현재는 사용하지않는다고 알게되었습니다.
나름 바꾸면서 진행중인데
authenticationManager() 를 사용하려면 어떻게해야되는지 알 수 있을까요?
Answer 1
4
authenticationManager 빈을 하나 생성하셔서 사용하시면 될 것 같습니다.
@Bean
AuthenticationManager authenticationManager(AuthenticationConfiguration authConfiguration) throws Exception {
return authConfiguration.getAuthenticationManager();
}
@Bean
public SecurityFilterChain configure(HttpSecurity http) throws Exception {
AuthenticationManager authenticationManager = authenticationManager(http.getSharedObject(AuthenticationConfiguration.class));
http.~~~
.addFilter(getAuthenticationFilter(authenticationManager));
return http.build();
}
private AuthenticationFilter getAuthenticationFilter(AuthenticationManager authenticationManager) {
AuthenticationFilter authenticationFilter = new AuthenticationFilter(authenticationManager);
return authenticationFilter;
}
또는
@Bean
public SecurityFilterChain configure(HttpSecurity http) throws Exception {
http.~~~
.addFilter(getAuthenticationFilter(http));
return http.build();
}
private AuthenticationFilter getAuthenticationFilter(HttpSecurity http) {
AuthenticationFilter authenticationFilter = new AuthenticationFilter(http.getSharedObject(AuthenticationConfiguration.class));
return authenticationFilter;
}이렇게 추가하시고
AuthenticationFilter에서는
@RequiredArgsConstructor
public class AuthenticationFilter extends UsernamePasswordAuthenticationFilter{
private final AuthenticationManager authenticationManager;
//attemptAuthentication
//successAuthentication
}이렇게 적용해보시면 될 듯합니다.
kafka 업데이트 강의 듣고 시포요
0
83
1
강의 교안
0
71
1
마이크로서비스간 통신 시, 인증 처리
0
79
1
api gateway 에서 인증 처리
0
64
1
섹션 19 질문드립니다
0
51
1
강의 자료 업데이트
0
81
1
부하분산 강의 섹션
0
56
1
강의자료는 어디에서?
0
69
1
강의 자료는 어디서 다운 받을 수 있나요?
0
109
1
전체 사용자 조회시 오류
0
57
1
혹시 pk 외 별도의 id 를 부여한 이유가 있을까요 ??
0
109
2
학습 방향
0
94
2
카프카 커넥터 사용 목적 문의
0
85
2
kafka 강의
0
106
2
서비스 디스커버리 종류
0
86
2
강의 자료에 대해서 궁금해요
0
115
2
GlobalFilter, LoggingFilter가 동작하지 않습니다.
0
89
2
Kafka Source Connect 버전 에러
0
83
2
소스커넥터는 사용안한 거 맞죠?
0
81
2
강의자료 업데이트 문의
0
94
2
강의에서 BCryptPasswordEncoder 에 역할(5-2)
0
56
1
강의 업데이트 계획이 궁금합니다.
0
111
2
MSA 애플리케이션에 Spring Web과 Spring Data JPA를 사용하는 것이 바람직한지 궁금합니다. (MSA 설계와 관련된 질문입니다)
0
160
2
어떤 것이 업데이트 된 건가요?
0
162
2

