Skip to content

Make oAuth request with load balanced web client #9500

Closed
@Munoon

Description

@Munoon

Expected Behavior
I want to make some oAuth requests using a loadbalancer. For example, requests to get a token, refresh a token, or request user information. I want to use multiple service instances to make this requests, not just one. For example, I want to use eureka to specify service instance for each token request.

Current Behavior
To make it by hand, I should override beans, that makes this request and set to them custom web client. Example:

@Bean
DefaultReactiveOAuth2UserService defaultReactiveOAuth2UserService() {
    var userService = new DefaultReactiveOAuth2UserService();
    userService.setWebClient(loadBalancedWebClient);
    return userService;
}

@Bean
ReactiveOAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> reactiveOAuth2AccessTokenResponseClient() {
    var accessTokenResponseClient = new WebClientReactiveAuthorizationCodeTokenResponseClient();
    accessTokenResponseClient.setWebClient(loadBalancedWebClient);
    return accessTokenResponseClient;
}

But, for example, it is really hard to set custom web client for AbstractWebClientReactiveOAuth2AccessTokenResponseClient, which make request to refresh expired token.

Context
Because of this problems, it is really hard to make our microservice system scalable. Framework require to use only one specified server, which is really bad.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)status: duplicateA duplicate of another issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions