【发布时间】:2016-04-27 05:09:34
【问题描述】:
我是 Spring OAuth 2 的新手。我想知道如何使用 Spring OAuth 2.0 在资源服务器中动态配置 Httpsecurity。由于我有存储在数据库中的antMatchers 和scopes 列表(将来可能会添加antMatchers 和scopes)。
对于单个antMatchers 和scope,我已经尝试如下,它按预期工作:
@Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/adminservice/")
.access("#oauth2.hasScope('Products')");
}
如果数据库中存储有antMatchers和scopes的列表如:
**antMatchers** **scopes**
/adminservice/ products
/xxxx/ yyyy
/yyyy/ xxxx
/jkjlk/ uyuuy
/klklk/ hjkskjk
在这里,当 spring 启动时,它自己想要在资源服务器中动态地从数据库中配置 antMatchers 和相应的 scope。
我怎样才能做到这一点?
【问题讨论】:
标签: java spring spring-security oauth-2.0