【问题标题】:POST method not working for permitAllPOST 方法不适用于 permitAll
【发布时间】:2018-01-11 17:10:15
【问题描述】:

我有以下带有弹簧安全的配置:

http.authorizeRequests()
                .antMatchers(
                        "/login",
                        "/webResources/**",
                        "/app/**",
                        "/",
                        "/core/landingPage",
                        "/api/genders",
                        "/ums/signup").permitAll()
                .and()
                .authorizeRequests()
                    .antMatchers("/**").authenticated()
                .and().formLogin()
                .loginPage("/login").permitAll()
                .usernameParameter("username")
                .passwordParameter("password")
                .and().csrf()
                .and().exceptionHandling().accessDeniedPage("/accessDenied");

问题是 /ums/signup 是 PostMapping 并且它不起作用。每当我尝试访问此端点时,它都会将我重定向到登录页面。我错过了什么?

【问题讨论】:

  • 你能展示你的/ums/signup类声明和方法声明吗?

标签: spring spring-mvc spring-security


【解决方案1】:

重写重载的configure方法public void configure(WebSecurity web) throws Exception并添加

web.ignoring().antMatchers("/ums/signup");

【讨论】:

    猜你喜欢
    • 2023-03-24
    • 2021-11-04
    • 2020-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-08
    • 2019-04-26
    相关资源
    最近更新 更多