-
Notifications
You must be signed in to change notification settings - Fork 6k
AbstractAuthenticationFailureEvent
published twice when parent ProviderManager
throws ProviderNotFoundException
#10206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@theborakompanioni I'm finding it difficult to follow the scenario. Can you please provide a minimal sample or a test? |
Hey @jgrandja, thanks for the follow-up. Hm, if you'd be willing to see this test in In this test I tried to show that the issue is reproducible. If you place a breakpoint in I tried to explain it more clearly but always end up with the steps I already provided in the issue description. I hope I'll soon have the time to download the spring-security source and try to come up with a solution/test/example if it cannot be reproduced on your end. Thank your for your time. |
@theborakompanioni I'll wait until you provide a minimal sample or test. There are a lot of dependencies in |
Hope this is a useful minimal sample for you to determine if this is a bug or intended behavior: theborakompanioni@ba98c94 If you need any more information, please feel free to reach out. Have a nice day! edit: all |
Thanks for the sample test @theborakompanioni. This really helped me clarify the scenario. In short, this is expected behaviour. If an However, the The end result is 2 Now, if you were to modify What I would recommend to avoid the For example, let's assume a However, if there are 2x sources for the user database, then it would make sense to have the secondary I hope this makes sense? I'm going to close this as the behaviour is expected. I believe adjusting your |
Thank you for your feedback and your time @jgrandja. This behaviour was not triggered by 2 sources for the user database. This setup originates from this configuration: https://github.com/theborakompanioni/bitcoin-spring-boot-starter/blob/378838a3c8bea46fc84bf520318ced627f0dbc13/incubator/spring-lnurl/spring-lnurl-auth-example-application/src/main/java/org/tbk/lightning/lnurl/example/LnurlAuthExampleApplicationSecurityConfig.java#L69-L121 (no I do not know how a configuration you describted would be setup.. guess I have to deep dive into the inner workings of the code more thoroughly. Thank you. |
I am currently running into an issue with
ProviderManager
hierarchy and its error handling with regards to a custom AuthenticationProvider.AuthenticationProvider
throwsBadCredentialsException
AuthenticationManager
is called and throwsProviderNotFoundException
ProviderNotFoundException
is published viaAuthenticationEventPublisher#publishAuthenticationFailure
BadCredentialsException
is also published as the exception of the parent is not saved inparentException
. Hence the event is published additionallyExpected would be, that if the parent does not have any providers supporting the
Authentication
, the child exception takes precedence.This is behaviour is partly guarded by tests
ProviderManagerTests#providerNotFoundFromParentIsIgnored
ProviderManagerTests#authenticateWhenFailsInParentAndPublishesThenChildDoesNotPublish
.. but it seems it does not take into account a parent provider that throw
ProviderNotFoundException
(the mocks in the test hides the fact that the parent itself will publish (if it is of classProviderManager
)).Can this be prevented by probing if the parent has any supporting providers before calling its
authenticate
method?Maybe my setup is somehow invalid.. but it is quite a small example application and I'd say mostly defaults. Maybe it is not supported for a
ProviderManager
to have anotherProviderManager
instance as parent.Related #6281
The text was updated successfully, but these errors were encountered: