Support multiple client-registration-id configurations
Multiple registration ids
In some environments it is required to support targeting multiple Oauth2 servers. The current solution for non-load-balanced feign clients only provide a single client-registration-id with the property spring.cloud.openfeign.oauth2.client-registration-id, so this is not possible.
Proposed solution
Add a new configuration: spring.cloud.openfeign.oauth2.client-registration-ids which should be a Map<String, String> mapping feign clients by name to a registration id. The default should still be spring.cloud.openfeign.oauth2.client-registration-id so there are no backward compatibility issues.
Other alternatives considered
- Using load-balanced clients
- Downsides
- A new
spring.security.oauth2.client.registrationandspring.security.oauth2.client.providermust be provided per each client if the clients use discrete names - Using the same name makes it difficult to do ad-hoc switching of hostname for a single client
- The logs do not show the actual URL called, which makes debugging much more difficult
- A new
- Downsides
- Make a local custom
OAuth2AccessTokenInterceptor
Hi @ryanjbaxter, @spencergibb I have opened PR #1459 to address this issue.
The implementation adds support for configuring multiple OAuth2 client registration IDs per Feign client while preserving the existing global client-registration-id behavior for backward compatibility.
I have also added tests covering client-specific registration IDs, multiple Feign clients, fallback behavior, and auto-configuration, along with the documentation updates.
Could you please review the changes and let me know if any modifications are needed?
Thanks!