使用Spring Security无需身份验证和授权

编程入门 行业动态 更新时间:2024-10-27 04:33:50
本文介绍了使用Spring Security无需身份验证和授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的项目要求我将Spring Security用于CSRF和XSS保护,但不能用于身份验证和授权.我已经在应用程序中配置了SS,但是每次访问页面时,它都会自动将我重定向到其登录"页面.如何禁用此功能?我的SecurityConfig文件是:

My project requires that I use Spring Security for CSRF and XSS protection but not to use it for the authentication and authorization. I have configured SS into my application but every time I access a page, it automatically redirects me to it's Login page. How do I disable this? My SecurityConfig file is:

@EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { } }

推荐答案

以下给出的SecurityConfig将允许所有请求都未经身份验证,但将具有CSRF和XSS防护:

The SecurityConfig as given below will allow all requests to be not authenticated, but will have the CSRF and XSS guards:

@EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().anyRequest().permitAll(); } }

更多推荐

使用Spring Security无需身份验证和授权

本文发布于:2023-10-28 20:01:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份验证   Spring   Security

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!