Skip to content

[FEATURE REQ] AadResourceServerConfiguration should support proxy #44977

Open
@dkellenb

Description

@dkellenb

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

Metadata

Metadata

Assignees

Labels

azure-springAll azure-spring related issuescustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions