spring-projects / spring-projects/spring-security

Introducing new PasswordHasher interface alongside PasswordEncoder

Open
#19,261 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: enhancement
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Expected Behavior

A PasswordEncoder interface should exist as the correct abstraction for password hashing operations, with PasswordEncoder depricated in its favor. The new interface would carry the same contract (hash() and matches() methods) but with naming that accurately reflects the one-way nature of the operation.

Current Behavior

PasswordEncoder is the only interface for password hashing. The name implies a reversible encoding operation, but it obviously is a one way operation or should be, if not. This is probably a semantic mismatch. Encoding is by definition reversible, hashing is not. The current naming causes confusion for developers learning Spring Security, as they must understand why a "password encoder" is used for something that is explicitly not encoding.

Context

This misleading name creates a source of confusion for developers new to Spring Security. Developers are taught that passwords must be hashed (not encoded, not encrypted) for security reasons and imagine then immediately told to implement PasswordEncoder. The contradiction requires extra explanation that should not be necessary.

The proposed change is non-breaking:

  • Introduce a PasswordHasher interface with the same contract
  • Deprecate PasswordEncoder pointing to PasswordHasher as its replacement
  • Existing implementations and code continue to compile and work unchanged

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing PasswordEncoder interface and its hash() and matches() contract, then inspect current implementations and compatibility coverage. Determine how a PasswordHasher replacement and PasswordEncoder deprecation would preserve existing code. Done means the new abstraction is available, the old name remains compatible and deprecated, and the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
authentication, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.