Skip to content

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

Closed
@spring-projects-issues

Description

@spring-projects-issues

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: configAn issue in spring-security-configin: coreAn issue in spring-security-corestatus: duplicateA duplicate of another issuetype: enhancementA general enhancementtype: jiraAn issue that was migrated from JIRA

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions