Azure / Azure/azure-sdk-for-java

[FEATURE REQ] AadResourceServerConfiguration should support proxy

Open
#44,977 3 comments 0 reactions 1 assignee Claimed by @rujche View on GitHub
azure-spring customer-reported feature-request needs-team-attention
Dominant language
Java
Stars
2.6k
Forks
2.2k
Avg merge
1d 22h
Merged PRs (30d)
159

Description

**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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.