azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

[FEATURE REQ] AadResourceServerConfiguration should support proxy

Open dkellenb opened this issue 10 months ago • 3 comments

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:

@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<OAuth2TokenValidator<Jwt>> validators = createDefaultValidator(aadAuthenticationProperties);
        nimbusJwtDecoder.setJwtValidator(new DelegatingOAuth2TokenValidator<>(validators));
        return nimbusJwtDecoder;
    }

// ... and more to copy & paste

dkellenb avatar Apr 15 '25 08:04 dkellenb

Thanks for filing this issue @dkellenb

@saragluna could you find an owner for this?

alzimmermsft avatar Apr 15 '25 13:04 alzimmermsft

We will close this issue as it has been open for a while. If you have any further questions or need assistance, please feel free to reopen it. Thank you!

Netyyyy avatar Oct 24 '25 04:10 Netyyyy

Issue is still present (version 5.23.0). @Netyyyy : Please reconsider.

dkellenb avatar Oct 24 '25 06:10 dkellenb