我的项目要求我使用 Spring Security 进行 CSRF 和 XSS 保护,但不使用它进行身份验证和授权。我已将 SS 配置到我的应用程序中,但每次访问页面时,它都会自动将我重定向到其登录页面。我如何禁用此功能?我的 SecurityConfig
文件是:
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth)
throws Exception {
}
}
最佳答案
下面给出的 SecurityConfig
将允许所有请求不进行身份验证,但将具有 CSRF 和 XSS 防护:
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().permitAll();
}
}
关于java - 没有使用 Spring Security 进行身份验证和授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29138483/