【发布时间】:2017-02-16 01:32:44
【问题描述】:
我玩了一下弹簧启动安全性。我使用 mongodb、spring-boot-starter-data-rest、spring-boot-starter-security 和 spring-boot-starter-web。我使用了像 REST 服务这样的自动 expos 存储库的可能性。我有两个存储库用户和客户。用户存储库用于帐户。 像这样扩展 WebSecurityConfigurerAdapter 后:
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http.authorizeRequests()
.antMatchers("/users/**")
.hasRole("ADMIN").antMatchers("/", "/customers")
.hasRole("USER")
.anyRequest().authenticated()
.and()
.formLogin().permitAll();
}
A 无法控制具有 ADMIN 角色的用户对 /users/ 页面的访问。我在访问服务时获得了身份验证,但是每个具有每个角色的用户都可以在任何地方访问。还应该配置什么?
【问题讨论】:
标签: java spring mongodb spring-security spring-boot