Skip to content

SEC-2620: Make CachingUserDetailsService constructor public for easy use in Java Config #2837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jun 10, 2014 · 6 comments
Labels
in: config An issue in spring-security-config in: core An issue in spring-security-core status: duplicate A duplicate of another issue type: enhancement A general enhancement type: jira An issue that was migrated from JIRA

Comments

@spring-projects-issues
Copy link

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.

@spring-projects-issues spring-projects-issues added in: core An issue in spring-security-core in: config An issue in spring-security-config Open type: enhancement A general enhancement type: jira An issue that was migrated from JIRA labels Feb 5, 2016
@spring-projects-issues spring-projects-issues added this to the 4.0 Backlog milestone Feb 5, 2016
@ezraroi
Copy link

ezraroi commented Aug 7, 2016

Any update on this? How can I use CachingUserDetailsService in my code? Currently i copied the code and made the constructor public

@rwinch rwinch modified the milestone: 4.0 Backlog Aug 15, 2016
@mdeinum
Copy link
Contributor

mdeinum commented Nov 25, 2016

@mofadeyunduo
Copy link

I have trouble too. How can I user CachingUserDetailsService? It has no document comments!

@rwinch rwinch removed the Open label May 3, 2019
@Smith-Cruise
Copy link

I have trouble too!!!!!

@linghengqian
Copy link

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 #6196 , this issue should be closed to avoid misleading people.

@eleftherias
Copy link
Contributor

Thanks @linghengqian! I'm closing this issue as per the comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: config An issue in spring-security-config in: core An issue in spring-security-core status: duplicate A duplicate of another issue type: enhancement A general enhancement type: jira An issue that was migrated from JIRA
Projects
None yet
Development

No branches or pull requests

8 participants