-
Notifications
You must be signed in to change notification settings - Fork 6k
Infinite recursion in WebSecurityConfigurerAdapter.java. #11088
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
Hi @Milan-Toliya, I could not simulate the issue here since there is a lot of unknown stuff going on. I did research on the repository's issues and did not find anything related, we really need a minimal, reproducible sample so we can make sure that this is a problem with Spring Security and not with the application setup. Are you able to isolate the issue? Thank you. |
I am able to simulate the issue of infinite recursion for the I will share the code here so you have look. |
Hi @marcusdacoregio, Apologies for the late reply. As per the earlier discussion what I am able to reproduce is the I have uploaded the code to my Github repository. Focus only on the Note: I have figured out the issue and fixed it in the actual project. The above project is just for the reference for the fix of #11071 Thanks. |
Hi @Milan-Toliya, I took a look at your repository but there is a lot going on. Also, there are no steps to reproduce the issue so it became hard for me to figure out what is happening. In order to be able to simulate the problem, we really need a minimal, reproducible sample with tests or steps to reproduce the issue. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing in favor of #12343 |
Bug
Infinite recursion in
WebSecurityConfigurerAdapter.java
.Refer PR where this issue and its solution are committed.
To Reproduce
WebSecurityConfigurerAdapter
. (NOTE: I have two Implementation ofWebSecurityConfigurerAdapter
)UserDetailsService
(Interface) is auto wired withUserDetailsServiceDelegator
(Inner class of the WebSecurityConfigurerAdapter)/helloworld
)userDetailsService.loadUserByUsername(username)
(ISSUE Infinite recursion loop in the methoduserDetailsService.loadUserByUsername
whenuserDetailsService
is instance ofUserDetailsServiceDelegator
)UserDetailsService
(Interface) is auto wiring withInMemoryUserDetailsManager
which it actually should in a positive case. Not sure how I managed to get in 2nd step's state earlier.Refer Below Image for classes mention above.

NOTE: I did not get an issue with
AuthenticationManagerDelegator.authenticate()
but By looking at the code it clearly visible that it suffers from the same infinite recursion loop whenthis == this.delegate
(refer to the code change I have proposed or look at the source code )Expected behavior
Instead of going into the Infinite recursion, it should follow the positive flow or should throw any Exception (Which I have suggested as a solution in PR. I am throwing IllegalStateException). Code MUST NOT go into infinite recursion (i.e. Stack overflow state)
The text was updated successfully, but these errors were encountered: