Oauth 2.0 - Single resource server but multiple client applications(OAuth 2.0-单资源服务器但多个客户端应用程序)
问题描述
问候语,
我想问以下是不是OAuth 2.0的有效用例:
- 授权服务器(单独)
 - 单个(或多个)资源服务器
 - 多个客户端应用程序访问同一资源服务器。
 
如果这是有效的用例,我们如何使用授权服务器配置多个客户端。无法使用APPLICATION.PROPERTIES(APPLICATION.YML)进行配置。
security.oauth2.client.client-id=dummy
security.oauth2.client.client-secret=password
或
security:
  oauth2:
    resource:
      token-info-uri: http://localhost:8080/oauth/check_token
    client:
      client-id: dummy
      client-secret: password
在这种情况下,多个客户端应用程序的正确配置是什么?
推荐答案
因此,如果您有多个客户端,则可以通过扩展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.java
这篇关于OAuth 2.0-单资源服务器但多个客户端应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:OAuth 2.0-单资源服务器但多个客户端应用程序
				
        
 
            
        - GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
 - 转换 ldap 日期 2022-01-01
 - 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
 - 如何指定 CORS 的响应标头? 2022-01-01
 - 未找到/usr/local/lib 中的库 2022-01-01
 - 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
 - 获取数字的最后一位 2022-01-01
 - Eclipse 的最佳 XML 编辑器 2022-01-01
 - java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
 - 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
 
						
						
						
						
						
				
				
				
				