Skip to content
Ameen Abozaid
Planned lessonJNR-037-L03

PasswordEncoder and upgrades

  • Lesson 3 of 5
  • Junior
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

store and check passwords with Spring's PasswordEncoder.

Planned topics

  • PasswordEncoder has encode(raw) and matches(raw, stored).
  • Use BCryptPasswordEncoder or Argon2PasswordEncoder.
  • PasswordEncoderFactories.createDelegatingPasswordEncoder() stores an id prefix like {bcrypt}, so you can change algorithms later.
  • upgradeEncoding tells you when a stored hash is weaker than the current setting; re-hash on the next successful login.
  • Expose the encoder as a @Bean; Spring Security picks it up.
Draft outline details

Demonstration

java
@Bean
PasswordEncoder passwordEncoder() {
    return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}

Check your understanding

What does the {bcrypt} prefix make possible?

Show answer

Moving to a new algorithm later while old hashes still work.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.