码迷,mamicode.com
首页 > 编程语言 > 详细

springSecurity5 重定向登录页面后 报错:尝试清除 Cookie.net::ERR_TOO_MANY_REDIRECTS status:200

时间:2019-12-08 00:53:38      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:color   定向   权限   mys   man   OLE   ant   perm   protect   

springSecurity5 使用:

http.formLogin().loginPage("/login");
报错如下图:

技术图片

 

springsucurity5 中 需要给 自己定义的请求加权限:

失败代码如下:

public class MySecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
//定制请求的授权规则
        http.authorizeRequests().antMatchers("/").permitAll()
                .antMatchers("/manage/**").hasRole("manage")
                .antMatchers("/view/**").hasRole("view")
                .antMatchers("/db/**").hasRole("db").anyRequest().authenticated();
        http.formLogin().loginPage("/login");

修正后代码如下:

public class MySecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().antMatchers("/").permitAll()
                .antMatchers("/login").permitAll()
                .antMatchers("/manage/**").hasRole("manage")
                .antMatchers("/view/**").hasRole("view")
                .antMatchers("/db/**").hasRole("db").anyRequest().authenticated();
//http.formLogin();
        http.formLogin().loginPage("/login");

 

 

 

springSecurity5 重定向登录页面后 报错:尝试清除 Cookie.net::ERR_TOO_MANY_REDIRECTS status:200

标签:color   定向   权限   mys   man   OLE   ant   perm   protect   

原文地址:https://www.cnblogs.com/belen87/p/12004004.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!