-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Spring WebClient is not using Proxy for the latest version of spring-security-oauth2-client-5.3.4.RELEASE #8966
Comments
@kmariappan2016 Based on my understanding, you are not able to call a protected resource using If this is the case, what is the difference in your configuration between 5.3.0 and 5.3.4? |
There is no change in configuration(proxy) between 5.3.0 and 5.3.4. I am keeping the same config. Let me know if any further details required. Thanks, |
@kmariappan2016 Can you please provide a minimal reproducible sample via a GitHub repo and then I can help troubleshoot. |
Unfortunately I can not provide the code via GitHub as my organization policy blocks it. I am connecting a resource behind corporate proxy and I have the proxy config as follows using Reactor HTTP Netty.
I thought its netty reactor issue, but if I switch to 5.3.0 of spring webclient it started working. |
@kmariappan2016 I'm guessing this is not an |
Here is the oAuth2 client config.
If you try to invoke API endppont, I am getting the error as its not taking the proxy config. Note. I raised with Reactor Netty Team and had a troubleshoot session.If its netty issue, it should not work with even 5.3.0 RELEASE |
@kmariappan2016 As mentioned in this comment, I need a minimal reproducible sample via a GitHub repo that I can clone and reproduce with minimal effort on my end. |
I will upload the details in a day with GitHub and provide you the link. Thanks, |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Hi, |
@kmariappan2016 The sample you provided does not reproduce the issue and it wasn't complete. I had to add The Although I don't see any reproducible issue here, this is not related to |
@kmariappan2016 I now see the issue with your configuration in The Here is the custom configuration for WebClient webClient = ... \\ TODO: Configure the `WebClient` with the `ClientHttpConnector`
AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager authorizedClientManager =
new AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager(
clientRegistrations, authorizedClientService);
authorizedClientManager.setAuthorizedClientProvider(createAuthorizedClientProvider(webClient)); Make sure the private ReactiveOAuth2AuthorizedClientProvider createAuthorizedClientProvider(WebClient webClient) {
WebClientReactiveClientCredentialsTokenResponseClient clientCredentialsTokenResponseClient
= new WebClientReactiveClientCredentialsTokenResponseClient();
clientCredentialsTokenResponseClient.setWebClient(webClient);
return ReactiveOAuth2AuthorizedClientProviderBuilder.builder()
.clientCredentials(builder -> builder.accessTokenResponseClient(clientCredentialsTokenResponseClient))
.build();
} This should solve your issue. |
Sure,I will try and update here. Thanks much |
It seems it get token behind proxy.but API endpoint is never getting called.Should I create another instance of Webclient to call the actual API endpoint? Thanks, |
@kmariappan2016 I'm glad you were able to resolve the issue and obtain the token behind the proxy. I'm not sure why the API endpoint is not being called. I don't think you need to create a new instance of |
Thanks, It returns the token endpoint call with 200 OK after that,its not at all calling the API endpoint and gets timed out. Need to investigate further and hope you would assist if you know something. Thanks, |
Hi, I am also running into the same issue. I tried using the proxy enabled WebClient to create custom ReactiveOAuth2AuthorizedClientProvider. Webclient config can be found here: https://github.com/easyRider651/proxy-server-test/blob/main/src/main/java/test/WebClientConfig.java I'll highly appreciate any help that I can get :) |
I could not able to connect to OAuth2 Resource behind proxy if I use the latest spring-security-oauth2-client-5.3.4.RELEASE.
I am using the reactor netty httpclient to set the proxy as follows.
HttpClient httpClient = HttpClient.create().tcpConfiguration(tcpClient -> tcpClient.proxy(
proxy -> proxy.type(ProxyProvider.Proxy.HTTP).host(proxyHost).port(Integer.valueOf(port)).build()));
ClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);
return WebClient.builder().clientConnector(connector).filter(oauth2FilterFunction).build();
But if I use spring-security-oauth2-client-5.3.0.RELEASE, I can able to connect via Proxy but the token is not associated with each request.
Advice me if I am doing anything wrong.
The text was updated successfully, but these errors were encountered: