Marten Deinum (Migrated from SEC-2620) said:
Trying to configure caching for anything else then the jdbcAuthentication() is painful. Where ldap caching is easily configured in XML that feature is (currently) not available in Java Config (at least I couldn't find it).
However to make caching configuration easier it would be nice if the CachingUserDetailsService could be made constructable from outside the package (maybe move to another package?). That way overriding the userDetailsService() method from the WebSecurityConfigurerAdapter would allow easy wrapping of the used UserDetailsService with caching
@Override
protected UserDetailsService userDetailsService() {
UserDetailsService delegate = super.userDetailsService();
CachingUserDetailsService userDetailsService = new CachingUserDetailsService(delegate);
userDetailsService.setUserCache(userCache());
return userDetailsService;
}
That way every UserDetailsService can be made cacheable without having to expose userCache methods for each configurer.
Comment From: ezraroi
Any update on this? How can I use CachingUserDetailsService in my code? Currently i copied the code and made the constructor public
Comment From: mdeinum
Apparently more people are having issues with this see http://stackoverflow.com/questions/40766098/springcachebasedusercache-is-null/40782952?noredirect=1#comment68816495_40782952.
Comment From: mofadeyunduo
I have trouble too. How can I user CachingUserDetailsService? It has no document comments!
Comment From: Smith-Cruise
I have trouble too!!!!!
Comment From: linghengqian
This problem has been solved long ago, and it is no longer necessary to build CachingUserDetailsService through ClassUtils.getConstructorIfAvailable(CachingUserDetailsService.class, UserDetailsService.class);, but to use the parameterized construction function directly. See https://github.com/spring-projects/spring-security/pull/6196 , this issue should be closed to avoid misleading people.
Comment From: eleftherias
Thanks @linghengqian! I'm closing this issue as per the comment above.