spring-attic / spring-security-oauth

Support for adding OAuth1(a) and OAuth2 features (consumer and provider) for Spring web applications.
http://github.com/spring-projects/spring-security-oauth
Apache License 2.0
4.69k stars 4.04k forks source link

support client side loadbalancing in OAuth2AccessTokenSupport #1503

Open lucwillems opened 5 years ago

lucwillems commented 5 years ago

The current OAuth2RestTemplate can be used together with @EnableDiscoveryClient and @Loadbalanced to access internal resources using a service registration like consul. access to the rest services is client side loadbalanced using the list of available services in consul.

this is however NOT possible for the URL used to acquire the oauth2 accessToken using client credentials. This results into java.net.UnknownHostException because the accessTokenUri doesn't have a valid hostname, only a services name which needs to be resolved using consul.

it would be great that Oauth2RestTemplate would also support @Loadbalanced for acquiring the oauth2 token from the internal Oauth2 services which are known in consul this would allow usage of client based loadbalancing and redundancy for acquiring oauth2 tokens.

wwhui commented 5 years ago

I also have this problem. I rewrote the getRestTemplate () method in XXAccessTokenProvider, but I don't know if there will be any problems.