spring-projects / spring-projects/spring-security

ProviderManager keeps trying other providers when CAS login fails

Open
#4,203 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

With multiple providers configured, say DaoAuthenticationProvider and CasAuthenticationProvider, when CAS login fails, ProviderManager keep trying other providers.

Actual Behavior

When a failed CAS login occurs, INVALID_TICKET for example, ProviderManager keep trying other providers configured, like DaoAuthenticationProvider, that uses the same authentication token class UsernamePasswordAuthenticationToken, which cause a BadCredentialsException to be the lastException on the iteration.
I don't know if the providers order can change something here.

Expected Behavior

CAS failed authentication should not try other providers.
A simple solution would be to create a different class from UsernamePasswordAuthenticationToken to use on CasAuthenticationFilter and CAS related authentication.
This will cause ProviderManager not to try other providers when the request is from a CAS server.

Configuration

Not available.

Version

4.1.3.RELEASE

Sample

Not available.

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

Trace ProviderManager's provider iteration with DaoAuthenticationProvider and CasAuthenticationProvider, then inspect how CasAuthenticationFilter creates UsernamePasswordAuthenticationToken. Reproduce the failed CAS login with multiple providers if possible; done means CAS authentication failures no longer fall through to other providers while normal provider selection still works.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.