spring-cloud-openfeign icon indicating copy to clipboard operation
spring-cloud-openfeign copied to clipboard

Support multiple client-registration-id configurations

Open jkstrauss opened this issue 8 months ago • 1 comments

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.registration and spring.security.oauth2.client.provider must 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
  • Make a local custom OAuth2AccessTokenInterceptor

jkstrauss avatar Mar 18 '26 14:03 jkstrauss

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!

yashdotdev13 avatar Nov 13 '26 06:11 yashdotdev13