Closed fbunsmann closed 2 years ago
Hi @fbunsmann,
With XsuaaAutoConfiguration
the XsuaaServiceConfiguration
bean is conditional on missing bean of this type, which means this bean should always be there and with that also one of the RestOperation beans get initialised, as long as you don't use RestOperations
bean you shouldn't see any exceptions even if you do not have xsuaa configuration present.
One option I see, if you don't have the XsuaaServiceConfiguration
and don't need the RestOperations
is to disable the autoconfiguration like so:
@EnableAutoConfiguration(exclude={XsuaaAutoConfiguration.class})
BR, Liga
With XsuaaAutoConfiguration the XsuaaServiceConfiguration bean is conditional on missing bean of this type, which means this bean should always be there
This is not correct, as XsuaaAutoConfiguration
allows to disable the default XsuaaServiceConfiguration
bean which XSUAA provides, by setting spring.xsuaa.disable-default-property-source
(see https://github.com/SAP/cloud-security-xsuaa-integration/blob/2.11.1/spring-xsuaa/src/main/java/com/sap/cloud/security/xsuaa/autoconfiguration/XsuaaAutoConfiguration.java#L48). CAP leverages that.
Please consider defining the MTLS RestOperations
conditional on XsuaaServiceConfiguration
, as also @fbunsmann suggested, as it is in fact conditional on that bean :)
And not using RestOperations
is unfortunately not enough to not see any exceptions, as this bean is not required in the use-case described by @fbunsmann, but nevertheless Spring still tries to create it and raises an exception due to the missing XsuaaServiceConfiguration
.
Ok, I see, thanks for additional information.
And not using RestOperations is unfortunately not enough to not see any exceptions
In case spring.xsuaa.disable-default-property-source
is not disabled it is enough.
Any objection disabling XsuaaAutoConfiguration
as a workaround? Doesn't seem that you need it.
Any objection disabling XsuaaAutoConfiguration as a workaround? Doesn't seem that you need it.
Yes as a workaround we are doing just that right now. It's just that more people will probably run into the same issue which is also not so easy to understand in the first place. Also I think from a logical perspective making xsuaaMtlsRestOperations
conditional on bean XsuaaServiceConfiguration
seems to be the right thing. Is there any specific reason why you would like to keep it as it is? If there is, the other alternative is that CAP updates their documentation and mentions the needed disabling of autoconfiguration there. I assume almost every consumer of CAP Java also uses spring-xsuaa
.
Any objection disabling XsuaaAutoConfiguration as a workaround? Doesn't seem that you need it.
Yes as a workaround we are doing just that right now. It's just that more people will probably run into the same issue which is also not so easy to understand in the first place. Also I think from a logical perspective making
xsuaaMtlsRestOperations
conditional on beanXsuaaServiceConfiguration
seems to be the right thing. Is there any specific reason why you would like to keep it as it is? If there is, the other alternative is that CAP updates their documentation and mentions the needed disabling of autoconfiguration there. I assume almost every consumer of CAP Java also usesspring-xsuaa
.
The change will come most likely in the 2.11.5 release, thanks for the insights 👍🏻
Thanks a lot! 👍
Question Summary
spring-xsuaa
version2.11.1
We are currently in the process of changing our xsuaa bindings to
x509
credentials for our spring applications. We are also using CAP as a framework, and we have discovered a small issue regarding theXsuaaAutoConfiguration
. For thex509
case, a beanxsuaaMtlsRestOperations
is configured which requires a parameter of typeXsuaaServiceConfiguration
. Usually, this is not a problem but with CAP there is use case to run a Cloud Foundry task for database migration on the java application which is executed with security disabled (because it does not expose any endpoints). You can check in their docs here. In this scenario, CAP does not provide any bean of typeXsuaaServiceConfiguration
and the application startup fails with the following exception:Would it be an option for you to only provide a bean
xsuaaMtlsRestOperations
ifXsuaaServiceConfiguration
is provided, or in other words to makexsuaaMtlsRestOperations
conditional on beanXsuaaServiceConfiguration
?If you have any further questions, let me know.
Regards, Florian