我正在将Spring Cloud与OAuth2结合使用。我有4个应用程序,如下所述:
1)Eureka服务器:服务注册。
2)zuul作为Api网关
3)验证服务器-成功验证后将access_token返回给客户端。
4)资源服务器-希望在授予对资源的访问权限之前先验证令牌。
我在application.properties中使用了以下配置:
security.oauth2.resource.tokenInfoUri=http://localhost:9600/oauth/check_token
security.oauth2.client.client-id=resourceServer-client
security.oauth2.client.client-secret=secret
我不想在application.properties中为“ tokenInfoUri”提供硬编码的ipaddress /主机名。 我想通过其服务名称访问身份验证服务器,因为可能有多个身份验证服务器实例。
我该怎么做?
我使用oauth2检查了tokenInfoUri在spring boot中如何工作的代码,发现
ResourceServerTokenServicesConfiguration -> RemoteTokenServicesConfiguration -> remoteTokenServices()
从ResourceServerProperties.java以@ConfigurationProperties检索tokenInfoUri的方法。
我不想使用JWT令牌进行令牌验证。我想使用从资源服务器到AuthServer的远程调用进行验证。