问候,
我想问以下是否是 Oauth 2.0 的有效用例:
- 授权服务器(单独)
- 单个(或多个)资源服务器
- 多个客户端应用程序访问同一资源服务器。
如果这是一个有效的用例,我们如何使用授权服务器配置多个客户端。无法使用 application.properties (application.yml) 进行配置。
security.oauth2.client.client-id=dummy
security.oauth2.client.client-secret=password
or
security:
oauth2:
resource:
token-info-uri: http://localhost:8080/oauth/check_token
client:
client-id: dummy
client-secret: password
在这种情况下,多客户端应用程序的正确配置是什么?
因此,如果您有多个客户端,您可以通过扩展在 AuthorizationServer 中注册客户端详细信息AuthorizationServerConfigurerAdapter
以下是如何在内存中注册客户详细信息的示例:
@EnableAuthorizationServer
@Configuration
public class AuthServerConfig extends AuthorizationServerConfigurerAdapter {
private final AuthenticationManager authenticationManager;
@Autowired
public AuthServerConfig(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
}
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient("egen")
.secret("{noop}egensecret")
.authorizedGrantTypes("authorization_code","refresh_token","password")
.scopes("food_read","food_write")
.and()
.withClient("oauthclient")
.secret("{noop}oauthclient-secret")
.authorizedGrantTypes("client_credentials", "refresh_token")
.authorities("ROLE_USER", "ROLE_OPERATOR")
.scopes("food_read");
}
///more code
}
有关更多详细信息,您可以查看我的 github 存储库:
https://github.com/Dovchiproeng/spring-cloud-security-oauth2-poc/blob/master/spring-cloud-secure-auth-server/src/main/java/com/egen/springcloudsecureauthserver/config/AuthServerConfig。爪哇 https://github.com/Dovchiproeng/spring-cloud-security-oauth2-poc/blob/master/spring-cloud-secure-auth-server/src/main/java/com/egen/springcloudsecureauthserver/config/AuthServerConfig.java
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)