【发布时间】:2015-11-05 10:05:37
【问题描述】:
我的Repository 中有以下示例方法(带有@RepositoryRestResource 注释):
@Override
@PreAuthorize("permitAll")
@PostAuthorize("permitAll")
public Iterable<User> findAll();
但是当我将这些 permitAll 注释添加到整个存储库界面时,我仍然收到 401 Unauthorized,事件。
这是我的WebSecurityConfigurerAdapter:
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Configuration
class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().fullyAuthenticated().and().httpBasic().and().csrf().disable();
}
}
我想这优先于那些方法注释,但我不知道如何解决这个问题。
【问题讨论】:
-
也许你错过了
permitAll中的括号。试试permitAll() -
你真的需要这些注释吗?删除它们后会发生什么?