교재상에는
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http
.authorizeRequests()
.requestMatchers("/login", "/signup", "/user").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/articles")
.and()
.logout()
.logoutSuccessUrl("/login")
.invalidateHttpSession(true)
.and()
.build();
}
으로 구현되어있는데 Spring Security가 버전이 올라가면서 deprecatd 된게 있는 것 같습니다. 그래서 저는
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception{
http
.authorizeHttpRequests((auth) -> auth
.requestMatchers("/login", "/signup", "/user").permitAll()
.anyRequest().authenticated()
)
.formLogin((formLogin) -> formLogin
.loginPage("/login")
.defaultSuccessUrl("/articles"));
http
.logout((logout) ->
logout.logoutSuccessUrl("/login")
.invalidateHttpSession(true)
);
http.csrf((csrf) -> csrf.disable());
return http.build();
}
이런식으로 수정하였습니다. 하지만 아래코드도 and() 부분에서 에러가 발생합니다.
@Bean
public AuthenticationManager authenticationManager(HttpSecurity http, BCryptPasswordEncoder bCryptPasswordEncoder, UserDetailService userDetailService) throws Exception {
return http.getSharedObject(AuthenticationManagerBuilder.class)
.userDetailsService(userService)
.passwordEncoder(bCryptPasswordEncoder)
.and()
.build();
}
이 코드는 어떻게 고쳐야할 지 모르겠습니다.
// 일단 이렇게 고쳐보았는데
@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception {
return authenticationConfiguration.getAuthenticationManager();
}
어떻게 수정하면 될까요?
https://docs.spring.io/spring-security/site/docs/current/api/deprecated-list.html
교재상에는
으로 구현되어있는데 Spring Security가 버전이 올라가면서 deprecatd 된게 있는 것 같습니다. 그래서 저는
이런식으로 수정하였습니다. 하지만 아래코드도 and() 부분에서 에러가 발생합니다.
이 코드는 어떻게 고쳐야할 지 모르겠습니다.
어떻게 수정하면 될까요?
https://docs.spring.io/spring-security/site/docs/current/api/deprecated-list.html