October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Why a Second Spring Security AuthenticationProvider Can Change Login Behavior

A second AuthenticationProvider is supported, but overlapping support, provider order, return values, exceptions, and manager wiring can change a login’s outcome.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Adding a second AuthenticationProvider is supported, but it can change which provider handles a login and whether authentication succeeds. The result depends on the Authentication type being checked, each provider’s supports and authenticate behavior, their order in the ProviderManager, and any parent manager or selected security filter chain.

How Spring Security delegates authentication

Spring Security filters use an AuthenticationManager to authenticate a request; ProviderManager is its most common implementation. A ProviderManager delegates the request to a list of AuthenticationProvider instances, which can handle different authentication mechanisms. Having multiple providers is an intended design, not an error by itself. Spring Security Servlet Authentication Architecture, 7.1.1

As an Amazon Associate I earn from qualifying purchases.

As the Spring Security documentation puts it, “Each AuthenticationProvider has an opportunity to indicate that authentication should be successful, fail, or indicate it cannot make a decision and allow a downstream AuthenticationProvider to decide.” The key distinction is between a provider that abstains and one that reports a failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What happens when a provider supports the request

supports(Class<?>) is a capability check: it indicates that a provider can evaluate an authentication class more closely. Returning true does not promise that the provider can authenticate the particular request. The provider’s authenticate(Authentication) result determines what happens next. Spring Security AuthenticationProvider API, 7.1.1

Provider outcome Effect on delegation
Returns a non-null Authentication The manager uses that result and stops checking later providers.
Returns null The provider cannot decide; the manager may continue to another supporting provider.
Throws an AuthenticationException The manager records the failure and can still use a later provider; if no later provider succeeds, the last authentication exception is rethrown.
Throws an AccountStatusException The manager stops querying providers rather than continuing down the list.

If no provider returns an authentication result and none can process the requested authentication type, the manager can throw ProviderNotFoundException. These iteration and exception rules are documented for ProviderManager 7.0.7. Spring Security ProviderManager API, 7.0.7

Why a second provider can cause a regression

The important change is often overlap. If the new provider and an existing provider both support the same authentication class, the new provider becomes part of the decision path. Its position and response now matter: it might return a result before the old provider is reached, abstain and allow the old provider to run, or throw an exception that affects the final outcome. An AccountStatusException stops the search outright.

For example, if a login flow produces an authentication token that both providers claim to support, the first matching provider gets an opportunity to process it. If it returns a non-null result, later providers are not consulted. If it returns null, delegation can continue. If it throws an ordinary AuthenticationException, a later provider may still succeed. Therefore, “the first provider failed” does not by itself establish whether Spring Security will try the next one; the exception type and whether a later provider succeeds both matter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Trace the failing login in this order

  1. Identify the request token. Determine the exact Authentication implementation created by the failing filter or login flow.
  2. Check provider matching and order. For every provider registered with the relevant manager, inspect the supports result for that class and establish the effective order.
  3. Observe the first provider’s outcome. Follow its authenticate call and determine whether it returns an authenticated object, returns null, throws an AuthenticationException, or throws an AccountStatusException.
  4. Check manager and filter-chain wiring. If no local provider handles the request, determine whether the ProviderManager has a parent AuthenticationManager. Also verify that the request is handled by the expected SecurityFilterChain; separate chains can use separate managers.
  5. Compare the working and failing configurations. Use a debugger or appropriate logs to confirm the registered providers, their order, and the runtime result. The general contract cannot identify an individual application’s actual wiring or custom-provider behavior.

Spring Security’s architecture documentation describes both provider delegation and parent-manager fallback. The core design is also documented in the 6.5.11 reference, so it is not limited to the 7.1.1 architecture page. Release-sensitive details should still be checked against the version used by the application. Spring Security Servlet Authentication Architecture, 6.5.11

Use a built-in provider as a comparison point

DaoAuthenticationProvider is Spring Security’s standard username-and-password example: it uses a UserDetailsService to load user data and a PasswordEncoder to check the password. Comparing a custom provider’s supported authentication type and outcome with this provider can help reveal overlap, but not every additional provider is for username-and-password authentication. Spring Security DaoAuthenticationProvider, 7.1.1

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the framework documentation cannot tell you

General documentation does not establish which provider your application registered first, which classes its custom providers support, whether they abstain or throw, or which filter chain handles a particular request. Those facts come from the application’s configuration and runtime behavior. The documented framework rules explain how to interpret those observations; they do not prove a particular cause without them.

Quick Recap

SaleBestseller No. 1
SaleBestseller No. 3
Bestseller No. 4
BookFactory Security Pass Down Log Book, Wire-O, 100 Pages
BookFactory Security Pass Down Log Book, Wire-O, 100 Pages
Made in USA - Proudly produced in Ohio by a Veteran-owned business
$22.99
Rank #4
BookFactory Security Pass Down Log Book, Wire-O, 100 Pages
  • Made in USA - Proudly produced in Ohio by a Veteran-owned business
  • Comprehensive Coverage: This BookFactory log book includes essential fields such as post/shift, time of change, date, weather conditions, and a designated space for detailed notes. This ensures that all relevant information is captured and easily accessible.
  • Sturdy Cover: The trans-lux cover protects the log book from wear and tear, ensuring its longevity and maintaining the integrity of your recorded data.
  • Essential Security Tool: This log book is an indispensable tool for any organization that values security and accountability. It helps to prevent misunderstandings, improve communication, and ensure a smooth transition between shifts.
  • Wire-O with Trans-lux cover, 100 Pages, Dimensions 8.5" x 11" - (Security-Pass-Down) Reorder SKU: LOG-100-7CW-PP(Security-Pass-Down)

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.