Tôi đã nhận được sau cấu hình Spring Security:Xuân Boot: accessDeniedHandler không hoạt động
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/api/private/**", "/app/**").authenticated();
http.csrf().disable();
http.logout().logoutSuccessUrl("/");
http.exceptionHandling().accessDeniedPage("/403"); //.accessDeniedHandler(accessDeniedHandler);
}
}
tôi mong đợi sau logic: không phải người dùng authenitcated sẽ được chuyển đến /403
. Thay vào đó, Spring hiển thị trang Tomcat 403 mặc định. Tôi cũng đã thử tùy chỉnh accessDeniedHandler
nếu không thành công.
Làm cách nào để triển khai logic tùy chỉnh khi truy cập bị lỗi?