Azure / Azure/azure-sdk-for-java
[FEATURE REQ] AadResourceServerConfiguration should support proxy
- Lingua principale
- Java
- Stelle
- 2.6k
- Fork
- 2.2k
- Merge medio
- 2g 2h
- PR unite (30g)
- 205
Descrizione
**Is your feature request related to a problem? Please describe.**
At the moment it's not possible to easily configure a proxy for the calls the calls to login.microsoft.com. The only way is to fully replace the whole `JwtDecoder` together with the `RestOperation` having the proxy configured.
**Describe the solution you'd like**
Please setup an easy way to configure a proxy for all calls done by the azure-sdk to azure.
**Describe alternatives you've considered**
The current alternative is to duplicate most of the code in `AadResourceServerConfiguration` and setup an extra RestTemplate for the JwtDecoder:
```java
@Bean
RestTemplate aadJwtRestTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("myproxyhost", 8080);
factory.setProxy(proxy);
return new RestTemplate(factory);
}
@Bean
JwtDecoder jwtDecoder(AadAuthenticationProperties aadAuthenticationProperties, RestTemplate aadJwtRestTemplate) {
AadAuthorizationServerEndpoints identityEndpoints = new AadAuthorizationServerEndpoints(
aadAuthenticationProperties.getProfile().getEnvironment().getActiveDirectoryEndpoint(), aadAuthenticationProperties.getProfile().getTenantId());
NimbusJwtDecoder nimbusJwtDecoder = NimbusJwtDecoder
.withJwkSetUri(identityEndpoints.getJwkSetEndpoint())
.restOperations(aadJwtRestTemplate) // <--- this is needed, as the current implementation has a static method call to createRestTemplate
.build();
List> validators = createDefaultValidator(aadAuthenticationProperties);
nimbusJwtDecoder.setJwtValidator(new DelegatingOAuth2TokenValidator<>(validators));
return nimbusJwtDecoder;
}
// ... and more to copy & paste
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.