Skip to content

DelegatingPasswordEncoder should provide additional argument to specify the encode algorithm #16827

@hannah23280

Description

@hannah23280

Currently, in DelegatingPasswordEncoder class

@Override
public String encode(CharSequence rawPassword) {
	return this.idPrefix + this.idForEncode + this.idSuffix + this.passwordEncoderForEncode.encode(rawPassword);
}

Enhancement: Add an overload method

@Override
public String encode(CharSequence rawPassword, String idForEncode) {
	return this.idPrefix + idForEncode + this.idSuffix + this.idToPasswordEncoder.get(idForEncode ).encode(rawPassword);
}

With this enhancement, we can now easily choose a different encoder when encoding a plain password.
This allows us to create the DelegatingPasswordEncoder using the simple api call PasswordEncoderFactories.createDelegatingPasswordEncoder() and yet able to use the created encoder to switch between different encoding algorithms whenever encoding is performed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions