spring-projects / spring-projects/spring-security
BasicAuthenticationFilter breaks SwitchUserFilter
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Describe the bug
When using the SwitchUserFilter with Basic auth, BasicAuthenticationFilter.authenticationIsRequired() fails when switched forcing a re-authentication.
To Reproduce
Enable both basic auth and the SwitchUserFilter, switch to a new user and then make another request.
BasicAuthenticationFilter.authenticationIsRequired() will return true since the current logged in user doesn't match the WWW-Authenticate header
Expected behavior
BasicAuthenticationFilter.authenticationIsRequired() should also check if existingAuth has a GrantedAuthority of ROLE_PREVIOUS_ADMINISTRATOR, and check that username against username
if (existingAuth instanceof UsernamePasswordAuthenticationToken
&& !existingAuth.getName().equals(username)) {
return true;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at BasicAuthenticationFilter.authenticationIsRequired() and reproduce the behavior with Basic auth and SwitchUserFilter enabled, switching to another user before making a second request. Done means a switched user does not trigger an unnecessary re-authentication when the existing authentication has ROLE_PREVIOUS_ADMINISTRATOR and matches the requested username.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100