【发布时间】:2016-12-22 11:39:17
【问题描述】:
我有一个具有以下配置的 Spring Boot 应用程序
@Configuration
@EnableWebSecurity
open class WebSecurityConfig : WebSecurityConfigurerAdapter() {
override fun configure(http:HttpSecurity) {
http
.authorizeRequests()
.antMatchers("/css/**", "/js/**", "/fonts/**")
.permitAll().and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.authorizeRequests()
.anyRequest().authenticated()
.and()
.logout()
.logoutSuccessUrl("/login")
.permitAll()
.and().csrf().disable()
}
@Autowired
fun configureGlobal(auth:AuthenticationManagerBuilder) {
auth
.inMemoryAuthentication()
.withUser("usr@provider.com").password("test").roles("USER")
}
}
当我尝试注销时,我得到了错误
出现意外错误(类型=不允许的方法,状态=405)。 不支持请求方法“POST”
我该如何解决?
如何重现
- 查看this repository的代码。
gradle bootRun- 转到
http://localhost:8080,分别输入usr@provider.com和test作为用户名和密码。 - 按注销按钮。
更新 1:这也不起作用。
http
.authorizeRequests()
.antMatchers("/css/**", "/js/**", "/fonts/**", "/logout")
.permitAll().and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.authorizeRequests()
.anyRequest().authenticated()
.and()
.csrf().disable()
【问题讨论】:
标签: java spring authentication spring-boot kotlin