SAP / cloud-security-services-integration-library

Integration libraries and samples for authenticating users and clients bound to XSUAA authentication and authorization service or Identity authentication service.
Apache License 2.0
151 stars 136 forks source link

@Cacheable in UaaTokenBroker breaks existing caching configs #107

Closed tyonchev closed 5 years ago

tyonchev commented 5 years ago

Hi Colleagues, If one tries to use UaaTokenBroker for getting client credentials tokens inside a project , where @EnableCaching has already been used, the ApplicationContext breaks on calls to the token broker with

Caused by: java.lang.IllegalStateException: No cache could be resolved for 'Builder[public java.lang.String com.sap.cloud.security.xsuaa.extractor.UaaTokenBroker.getAccessTokenFromClientCredentials(java.lang.String,java.lang.String,java.lang.String) throws com.sap.cloud.security.xsuaa.extractor.TokenBrokerException] caches=[] | key='' | keyGenerator='' | cacheManager='xsuaa.tokenbroker' | cacheResolver='' | condition='' | unless='' | sync='false'' using resolver 'org.springframework.cache.interceptor.SimpleCacheResolver@63bf7222'. At least one cache should be provided per cache operation.

Basically the problem is that you enforce the @Cacheable on getAccessTokenFromClientCredentials, is there a particular reason for that? When one tries to configure the needed CacheManager,that leads to this issue : https://stackoverflow.com/questions/56985988/how-to-use-enablecache-multiple-cachemanagers-and-a-custom-cache-resolver

nenaraab commented 5 years ago

Dear @tyonchev

thanks for this hint! Have you tried to mark your cacheManager bean as primary one?

What would be your proposal?

Thanks and best regards, Nena

nenaraab commented 5 years ago

Dear @tyonchev

This issue is solved with version 2.0.0: https://search.maven.org/search?q=com.sap.cloud.security

Please consider the release notes: https://github.com/SAP/cloud-security-xsuaa-integration/releases/tag/2.0.0

Best regards, Nena