spring-projects / spring-projects/spring-security

SEC-2663: Handle Password Policy Error status PASSWORD_EXPIRED

Open
#2,883 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Jürgen Failenschmid (Migrated from SEC-2663) said:

The Password Policy LDAP control/response is handled better since Spring Security 3.0. The decoding of responses includes org.springframework.security.ldap.ppolicy.PasswordPolicyErrorStatus#PASSWORD_EXPIRED and ACCOUNT_LOCKED.

However, org.springframework.security.ldap.ppolicy.PasswordPolicyAwareContextSource only checks ACCOUNT_LOCKED (ctrl.isLocked) and ignores PASSWORD_EXPIRED (ctrl.isExpired).

As a work-around I tried to override PasswordPolicyAwareContextSource.getContext(), but that is inefficient because by the time the LdapException can be caught, the directory context is already closed and would have to be opened again in order to retrieve the password policy control response. Therefore, I made a modified copy of the getContext() method to add checking for isExpired().
Note that the current implementation of org.springframework.security.ldap.authentication.LdapAuthenticationProvider assumes that the PasswordPolicyException will be thrown only in the case of ACCOUNT_LOCKED. So, I ended up throwing the CredentialsExpiredException directly from my extension of PasswordPolicyAwareContextSource.

It would be best if PasswordPolicyAwareContextSource supported PASSWORD_EXPIRED, or at least provided a straightforward way to extend the handling of password policy responses.

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 by reading PasswordPolicyAwareContextSource.getContext() and the handling in LdapAuthenticationProvider, focusing on PasswordPolicyErrorStatus.PASSWORD_EXPIRED versus ACCOUNT_LOCKED. Trace how the password policy response is available before the directory context closes. Done means expired-password responses are handled alongside locked accounts without requiring a custom copy of getContext().

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authentication, backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.