【发布时间】:2017-01-31 15:26:31
【问题描述】:
我正在创建 rest api 并实现 Spring Security - 一切正常,但我希望(目前,当我仍在开发时)能够让任何未经授权的人打开 localhost:8080/console。 我的代码:
@Override
protected void configure(HttpSecurity http) throws Exception {
// allow everyone to register an account; /console is just for testing
http.authorizeRequests().antMatchers("/register", "/console").permitAll();
http.authorizeRequests().anyRequest().fullyAuthenticated();
// making H2 console working
http.headers().frameOptions().disable();
/*
https://docs.spring.io/spring-security/site/docs/current/reference/html/csrf.html#when-to-use-csrf-protection
for non-browser APIs there is no need to use csrf protection
*/
http.csrf().disable();
}
真正奇怪的是 - localhost:8080/register 不需要任何身份验证,但 /console 返回:
{
"timestamp": 1485876313847,
"status": 403,
"error": "Forbidden",
"message": "Access Denied",
"path": "/console"
}
有人知道怎么解决吗?
【问题讨论】:
标签: java spring spring-security h2