我刚刚试验了Spring 4的安全性。我使用以下方法映射受保护的端点:
@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结构可能会变得很麻烦。
只是想知道是否有一种可能更“易于管理”的替代方法--我想这是不是有点主观?
发布于 2016-03-31 05:01:33
我可以建议有一个方法,只添加蚂蚁匹配。可能是映射到角色映射的路径,并将映射提供给该方法以添加匹配器。
https://stackoverflow.com/questions/36323996
复制相似问题