Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply oauth2 client configuration to WebClients not created by this starter #3

Open
oliemansm opened this issue May 24, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@oliemansm
Copy link
Member

Is your feature request related to a problem? Please describe.
The oauth2 properties are only applied to the WebClient created by this starter. When you need to connect to two different GraphQL endpoints you need two different GraphQLWebClient instances, both with their own WebClient instances containing the correct url. That's possible to do now by simply not using the auto-configuration features of this starter but by creating those instances manually.

In my case those GraphQL endpoints are secured by the same Identity Provider and I just have to apply one oauth2 configuration to make it work with both instances. Currently I'd have to copy paste the following logic when creating those WebClient instances:

    if (clientRegistrations != null && clientRegistrations.findByRegistrationId("graphql").blockOptional().isPresent()) {
      ServerOAuth2AuthorizedClientExchangeFilterFunction oauth =
          new ServerOAuth2AuthorizedClientExchangeFilterFunction(
              clientRegistrations,
              new UnAuthenticatedServerOAuth2AuthorizedClientRepository());
      oauth.setDefaultClientRegistrationId("graphql");
      clientBuilder.filter(oauth);
    }

Describe the solution you'd like
Extract applying the oauth2 client configuration from the method creating the WebClient instance. It should get a hold of the WebClient.Builder bean and apply this logic to it before the WebClient beans are created (manually or by this starter). That means that the WebClient bean construction that's outside of control of this library should happen after that "listener" too. Not sure yet how that dependency could be implemented correctly.

Describe alternatives you've considered
Copy pasting the logic and applying it manually.

Additional context
N/A

@oliemansm oliemansm added the enhancement New feature or request label May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant