-
Notifications
You must be signed in to change notification settings - Fork 142
Closed
Labels
Description
ℹ️ If you have a question, please post it on the Okta Developer Forum instead. Issues in this repository are reserved for bug reports and feature requests only.
I'm submitting a
- bug report
- feature request
Background info
Unable to use a JVM wide https proxy
Expected behavior
The jvm args -Dhttps.proxyHost=...., -Dhttps.proxyPort=3128 should be honoured and the proxy applied.
What went wrong?
The proxy is not used.
Steps to reproduce
It appears that setting proxy = Proxy.NO_PROXY; is causing the system-properties specified proxy to be ignored.
Line 107 in d8d670e
| requestFactory.setProxy(proxy); |
static RestTemplate restTemplate(OktaOAuth2Properties oktaOAuth2Properties) {
Proxy proxy;
OktaOAuth2Properties.Proxy proxyProperties = oktaOAuth2Properties.getProxy();
Optional<BasicAuthenticationInterceptor> basicAuthenticationInterceptor = Optional.empty();
if (proxyProperties != null && Strings.hasText(proxyProperties.getHost()) && proxyProperties.getPort() > 0) {
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyProperties.getHost(), proxyProperties.getPort()));
if (Strings.hasText(proxyProperties.getUsername()) &&
Strings.hasText(proxyProperties.getPassword())) {
basicAuthenticationInterceptor = Optional.of(new BasicAuthenticationInterceptor(proxyProperties.getUsername(),
proxyProperties.getPassword()));
}
} else {
proxy = Proxy.NO_PROXY;
}
RestTemplate restTemplate = new RestTemplate(Arrays.asList(
new FormHttpMessageConverter(), new OAuth2AccessTokenResponseHttpMessageConverter(), new StringHttpMessageConverter()
));
restTemplate.getInterceptors().add(new UserAgentRequestInterceptor());
basicAuthenticationInterceptor.ifPresent(restTemplate.getInterceptors()::add);
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setProxy(proxy);
restTemplate.setRequestFactory(requestFactory);
return restTemplate;
}
SDK Version
2.1.6
Reactions are currently unavailable