我在Repository
(与@RepositoryRestResource
注释)以下示例方法:@PreAuthorize(permitAll)仍需要验证
@Override
@PreAuthorize("permitAll")
@PostAuthorize("permitAll")
public Iterable<User> findAll();
但我仍然得到401 Unauthorized
,事件,当我添加这些permitAll
注释全储存库界面。
我得到这个作为我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();
}
}
我想这将优先于这些方法的注释,BU我不知道如何解决这个问题。
也许你遗漏了'permitAll'中的括号。尝试'permitAll()' –
你真的需要这些注释吗?当你删除它们会发生什么? –