Add algorithm prefix to encoded password
Update the CLI encodepassword command to also include the algorithm prefix. Closes gh-11875
This commit is contained in:
parent
1e3bae9ba2
commit
c8257b38a2
@ -100,7 +100,7 @@ public class EncodePasswordCommand extends OptionParsingCommand {
|
||||
.collectionToCommaDelimitedString(ENCODERS.keySet()));
|
||||
return ExitStatus.ERROR;
|
||||
}
|
||||
Log.info(encoder.get().encode(password));
|
||||
Log.info("{" + algorithm + "}" + encoder.get().encode(password));
|
||||
return ExitStatus.OK;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,7 @@ import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
import org.springframework.boot.cli.util.MockLog;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
|
||||
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@ -59,8 +58,9 @@ public class EncodePasswordCommandTests {
|
||||
EncodePasswordCommand command = new EncodePasswordCommand();
|
||||
ExitStatus status = command.run("boot");
|
||||
verify(this.log).info(this.message.capture());
|
||||
assertThat(new BCryptPasswordEncoder().matches("boot", this.message.getValue()))
|
||||
.isTrue();
|
||||
assertThat(this.message.getValue()).startsWith("{bcrypt}");
|
||||
assertThat(PasswordEncoderFactories.createDelegatingPasswordEncoder()
|
||||
.matches("boot", this.message.getValue())).isTrue();
|
||||
assertThat(status).isEqualTo(ExitStatus.OK);
|
||||
}
|
||||
|
||||
@ -69,8 +69,9 @@ public class EncodePasswordCommandTests {
|
||||
EncodePasswordCommand command = new EncodePasswordCommand();
|
||||
ExitStatus status = command.run("-a", "pbkdf2", "boot");
|
||||
verify(this.log).info(this.message.capture());
|
||||
assertThat(new Pbkdf2PasswordEncoder().matches("boot", this.message.getValue()))
|
||||
.isTrue();
|
||||
assertThat(this.message.getValue()).startsWith("{pbkdf2}");
|
||||
assertThat(PasswordEncoderFactories.createDelegatingPasswordEncoder()
|
||||
.matches("boot", this.message.getValue())).isTrue();
|
||||
assertThat(status).isEqualTo(ExitStatus.OK);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user