我正在使用Spring安全设置OAuth2.0授权服务器。我想知道在OAuth2.0授权服务器启动并运行后,是否有一种方法可以动态注册OAuth2.0客户端?
基本上,我知道我可以在配置OAuth2.0server时注册一个客户机,方法是扩展AuthorizationServerConfigurerAdapter并覆盖configure方法以在内存中添加客户机详细信息。然而,通过这种方式,客户端是预注册的,我想知道如何动态添加客户端详细信息。
`@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { // @formatter:off clients.inMemory() .withClient(CLIENT_ID) .secret(CLIENT_SECRET) .authorizedGrantTypes("authorization_code", "implicit") .redirectUris("http://junk/") .scopes("cn") .accessTokenValiditySeconds(600); // @formatter:on }`发布于 2016-07-14 17:22:55
您应该能够只使用JdbcClientDetails (甚至还有一些类似于内存中方法的方便方法):
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.jdbc(dataSource)
.passwordEncoder(passwordEncoder)
.withClient("my-trusted-client")
... etc.(代码摘自此处:https://github.com/spring-projects/spring-security-oauth/blob/master/tests/annotation/jdbc/src/main/java/demo/Application.java#L102。)然后,您就有了一个数据库,其中的数据可以在运行时随意更改。
https://stackoverflow.com/questions/35783430
复制相似问题