spring-projects / spring-projects/spring-security
SEC-2699: lazyBean() should be able to detect an existing @Lazy proxy
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Dave Syer (Migrated from SEC-2699) said:
The AuthenticationConfiguration.lazyBean(Class<T>) convenience method tries to detect existing beans of a given type and wrap them in a lazy proxy. If it comes across one that is already a scoped proxy (and therefore assumably lazy) it fails to detect that:
...
Caused by: java.lang.IllegalArgumentException: Expecting to only find a single bean for type interface org.springframework.security.authentication.AuthenticationManager, but found [scopedTarget.authenticationManager, authenticationManager]
at org.springframework.util.Assert.isTrue(Assert.java:65)
at org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration.lazyBean(AuthenticationConfiguration.java:112)
at org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration.getAuthenticationMangerBean(AuthenticationConfiguration.java:122)
at org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration.getAuthenticationManager(AuthenticationConfiguration.java:81)
...
In this case probably it should just return the existing proxy ("authenticationManager").
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 in AuthenticationConfiguration.java at lazyBean(), identified in the stack trace at line 112, and inspect how it handles the scopedTarget.authenticationManager and authenticationManager bean names. Reproduce the failure described in the issue and verify that an existing scoped proxy is detected and returned without triggering the single-bean assertion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100