AquestionforWebSecurityConfigurerAdapterdeprecated
创始人
2024-09-11 22:01:33
0

在Spring Security 5中,WebSecurityConfigurerAdapter已被弃用,可以使用更简单的方式配置安全性。可以使用@EnableWebSecurity注释以及实现WebSecurityConfigurer接口来配置安全性。示例代码如下:

@Configuration
@EnableWebSecurity
public class SecurityConfig implements WebSecurityConfigurer {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().antMatchers("/secure/**").authenticated().and().formLogin();
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .withUser("user")
                .password("{noop}password")
                .roles("USER");
    }
}

其中,configure(HttpSecurity http)方法用于配置请求授权,configure(AuthenticationManagerBuilder auth)方法用于配置用户身份验证。使用@EnableWebSecurity注释启用Web安全性。

相关内容

热门资讯

技术分享!wepoker有没有... 技术分享!wepoker有没有透视方法,wepoker一直输的号能继续打吗,确实是真的有挂(有挂方法...
攻略讲解!哈糖大菠萝免费辅助器... 攻略讲解!哈糖大菠萝免费辅助器,wepoker辅助脚本,总是真的是有挂(有挂秘籍)小薇(辅助器软件下...
重大通报!wpk辅助是什么,a... 重大通报!wpk辅助是什么,aapoker如何设置胜率,一贯存在有挂(有挂方法)1、下载好正确养号方...
玩家必看攻略!wepoker可... 玩家必看攻略!wepoker可以免费玩吗,hhpoker买挂,总是存在有挂(有挂解密)1、在插件功能...
最新通报!德普之星透视辅助软件... 最新通报!德普之星透视辅助软件是真的吗,德州局HHpoker透视脚本,真是真的是有挂(详细教程)1、...
最新技巧!wepoker辅助软... 最新技巧!wepoker辅助软件价格,fishpoker透视,一直是有挂(有挂技术)1、首先打开we...
今日重大通报!hhpoker怎... 今日重大通报!hhpoker怎么开透视,wejoker免费脚本,总是真的是有挂(揭秘有挂)1、点击下...
推荐一款!aa poker辅助... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...
热门推荐!微扑克辅助,wepo... 热门推荐!微扑克辅助,wepoker辅助器最新版本更新内容,真是有挂(发现有挂)1、玩家可以在wep...
一分钟揭秘!poker辅助器免... 一分钟揭秘!poker辅助器免费安装,破解辅助插件wepoker,都是存在有挂(有挂细节)1)辅助插...