0
我剛剛一直在試驗Spring 4的安全性。我使用下面的方法來經保密端點映射:Spring 4 Restful Security
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers(HttpMethod.GET, "/hello/*").hasRole("ADMIN")
.antMatchers(HttpMethod.GET, "/hello/**").hasRole("ADMIN")
.and()
.httpBasic()
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
它發生,我認爲,如果我有很多端點的.antMatchers結構可能成爲累贅。
只是想知道是否有一種可能更「可控」的替代方法 - 我猜這有點主觀?
考慮[XML配置](https://github.com/gmazza/tightblog/blob/trunk/app/src/main/webapp/WEB-INF/security.xml#L34)如果Java方式也變得太對你來說很麻煩。 –
從某種意義上講,Java Config旨在避免XML的「複雜性」 - 在這種情況下,XML實際上可能更清晰! – skyman