I have configured OAuth2 client in Spring Security as below

Spring Security Cannot use HTTP Proxy for OAuth2 client

It works well with Internet connection. When I run the app with VPN and outbound traffic through HTTP Proxy, I got the following error:

Spring Security Cannot use HTTP Proxy for OAuth2 client

By looking at the source code here: https://github.com/spring-projects/spring-security/blob/7c54c0e4fa7e026157f492002e4ef29809ec3a07/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistrations.java#LL60C1-L67C3

It seems that ClientRegistrations do not honour http.proxyHost and http.proxyPort properties during the creation of RestTemplate.

Please advise any workaround or solution so that we can use ClientRegistrations requesting OIDC metadata through Proxy. Thanks

Comment From: brbaje-matillion

We are also experiencing the same issue with our new SAAS agent, if there is an operational work round, that would be amazing.

Ben

Comment From: marcusdacoregio

Hi @kyyung, thanks for the report.

I believe that this is related to https://github.com/spring-projects/spring-security/issues/8882, therefore I'm closing this as a duplicate. If this is not related to #8882, we can reopen this.

You might want to add your use case to the other issue if it is not already covered there.