Skip to content

Commit 70367c1

Browse files
authored
Fix gh-254
Fix [gh-254](#254): Inject the authorized client manager and repository to SpringAddonsRestClientBeanDefinitionRegistryPostProcessor only when OAuth2 authorization is configured to use a registration.
1 parent 836102a commit 70367c1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-addons-starter-rest/src/main/java/com/c4_soft/springaddons/rest/synchronised/SpringAddonsRestClientBeanDefinitionRegistryPostProcessor.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ public void postProcessBeanDefinitionRegistry(@NonNull BeanDefinitionRegistry re
5959
final var builder = e.getValue().isExposeBuilder()
6060
? BeanDefinitionBuilder.genericBeanDefinition(RestClientBuilderFactoryBean.class)
6161
: BeanDefinitionBuilder.genericBeanDefinition(RestClientFactoryBean.class);
62+
final var oAuth2Authorization = e.getValue().getAuthorization().getOauth2();
6263
builder.addPropertyValue("systemProxyProperties", systemProxyProperties);
6364
builder.addPropertyValue("restProperties", restProperties);
64-
builder.addAutowiredProperty("authorizedClientManager");
65-
builder.addAutowiredProperty("authorizedClientRepository");
65+
if (oAuth2Authorization != null
66+
&& oAuth2Authorization.getOauth2RegistrationId().isPresent()) {
67+
builder.addAutowiredProperty("authorizedClientManager");
68+
builder.addAutowiredProperty("authorizedClientRepository");
69+
}
6670
builder.addAutowiredProperty("clientHttpRequestFactory");
6771
builder.addPropertyValue("clientId", e.getKey());
6872
registry.registerBeanDefinition(restProperties.getClientBeanName(e.getKey()),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy