我在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()' –
你真的需要這些註釋嗎?當你刪除它們會發生什麼? –