Skip to content

InitializeUserDetailsBeanManagerConfigurer should respect primary flag #17902

@quaff

Description

@quaff

Expected Behavior
If one of multiple UserDetailsService beans is primary, then it should be configured.

Current Behavior
Warning log message instead.

else if (beanNames.length > 1) {
this.logger.warn(LogMessage.format("Found %s UserDetailsService beans, with names %s. "
+ "Global Authentication Manager will not use a UserDetailsService for username/password login. "
+ "Consider publishing a single UserDetailsService bean.", beanNames.length,
Arrays.toString(beanNames)));
return;
}

Context

I want to enhance existing UserDetailsService like this:

    @Primary
    @Bean
    public UserDetailsService primaryUserDetailsService(UserDetailsService userDetailsService) {
        return (username) -> {
            // TODO load user from other source
            return userDetailsService.loadUserByUsername(username);
        };
    }

I'd like to contribute if it's accepted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions