研究了好几天的授权服务对资源服务是如何实现负载均衡的
真的是丈二和尚摸不着头脑,研究了几天今天终于找到了一篇文章 真的是翻;烂了 奈何自己太菜
上一下资源服务的yml配置(oauth-server是注册的服务)
security.oauth2.client.client-id=resource1
security.oauth2.client.client-secret=0
security.oauth2.client.user-authorization-uri=http://oauth-server:9015/oauth/authorize
security.oauth2.client.grant-type=password
security.oauth2.client.scope=read
security.oauth2.client.access-token-uri=http://oauth-server:9015/oauth/token
#需要jwt保存token的时候则需要配置下面的uri,拿到公共密钥
#security.oauth2.resource.jwt.key-uri=http://localhost:9015/oauth/token_key
#使用remoteServiec的时候则需要配置chekc端点
security.oauth2.resource.token-info-uri=http://oauth-server:9015/oauth/check_token
接下来请看摘抄
在微服务的构建中,将授权服务器注册在eureka上面。当客户端访问资源服务器的时候必须携带token进行认证和授权。如果我们在资源服务器上直接硬编码授权服务器地址,那么我们是不能够搭载高负载的授权服务器的,所以我们需要一个可以负载均衡的RestTemplate进行负载调用授权服务器。