Skip to content

Spring Authorization Server fails to start with multiple PasswordEncoder beans #1610

@Dayde

Description

@Dayde

Describe the bug
When having multiple PasswordEncoder declared as beans, Spring Authorization Server ignores the @Primary hint and fails to start because it finds multiple beans.

This behaviour is present since the beginning of the project. We’re using 0.4.5 but the reproducer joined below demonstrates the same problem with version 1.2.4.

To Reproduce
Declare multiple PasswordEncorder as components with one as @Primary

    @Bean
    fun bcryptPasswordEncoder(): PasswordEncoder {
        return BCryptPasswordEncoder()
    }

    @Bean
    @Primary
    fun delegatingPasswordEncoder(): PasswordEncoder {
        return PasswordEncoderFactories.createDelegatingPasswordEncoder()
    }

Expected behavior
The component declared as @Primary should be used.

Sample
Reproducer available here -> https://gitlab.com/maltcommunity/public/oss/spring-authorization-server-bug-reproducer/

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions