【发布时间】:2015-04-08 18:33:17
【问题描述】:
我们正在重新设计我们的产品以删除 SpringSecurity 中默认的“anonymousUser”行为,并希望锁定除少数端点之外的所有 URL(通过过滤器安全性)。我们想不通的是如何指定“锁定除 X、Y 和 Z 之外的所有内容”
我们的安全设置基本上归结为以下几点:
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
// disable anonymous users
.anonymous().disable()
// don't add ROLE_ to the role...
.authorizeRequests()
.regexMatchers("^/", "^/login", "^/mobile/login", "^/api/auth/.*")
.authenticated()
.and()
;
}
}
我采取的其他路线类似于:
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
// disable anonymous users
.anonymous().disable()
// don't add ROLE_ to the role...
.authorizeRequests()
.antMatchers("/**")
.authenticated()
.antMatchers("/", "/login", "/mobile/login", "/api/auth/**", "/reservations/**")
.permitAll()
.and()
;
}
}
任何建议/意见将不胜感激。
谢谢!
【问题讨论】:
标签: java spring spring-security