Skip to content
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

Switch to proxy-less configuration by leveraging @Configuration(proxyBeanMethods = false) #6818

Closed
sdeleuze opened this issue Apr 26, 2019 · 2 comments · Fixed by #6853
Closed
Assignees
Labels
in: config An issue in spring-security-config type: enhancement A general enhancement
Milestone

Comments

@sdeleuze
Copy link

sdeleuze commented Apr 26, 2019

As part of our Spring efficiency effort, we have recently migrated almost all @Confguration in Spring Framework 5.2 and Spring Boot 2.2 to be usable without CGLIB proxies. It would be great for end users and consistent from a portfolio perspective if Spring Security 5.2 could do the same.

This Spring Framework commit introduced a new proxyBeanMethods boolean attribute on @Configuration that when set to false avoid to create a CGLIB proxy for configuration classes. To be able to use this new capability you "just" have to replace eventual @Bean method invocations that where relying on CGLIB by explicit method parameter that will be injected without proxy.

@bclozel did that work on Spring MVC and Spring WebFlux configuration via this commit. You can also take inspiration from Spring Boot autoconfigurations which have been almost all updated with @Configuration(proxyBeanMethods = false). As a bonus, this would make Spring Security configurations GraalVM native image friendly for free ;-)

A possible process is to manually look through each @Configuration annotated class, do a "find usage" on each @Bean annotated method, replace invocation by parameter injection, and turn each @Configuration to @Configuration(proxyBeanMethods = false). Notice that if you need more flexibility with the bean retrieved, you can leverage ObjectProvider<Foo> parameters like that.

Side notes: I found #6613 on a connected topic, but targeting Spring Security 6.0 which will be too late for what is discussed here. Notice also that we took the decision to do breaking changes to Spring MVC and WebFlux configuration classes given the fact this topic is high priority for the Spring Boot 2.2 release train.

@rwinch
Copy link
Member

rwinch commented Apr 26, 2019

We can use https://github.com/wilkinsona/spring-boot-development-eclipse-plugin to help find places that need replaced

@eleftherias eleftherias self-assigned this May 6, 2019
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 7, 2019
@eleftherias eleftherias removed the status: waiting-for-triage An issue we've not yet triaged label May 14, 2019
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 14, 2019
eleftherias added a commit to eleftherias/spring-security that referenced this issue May 22, 2019
This is so that our configuration classes do not rely on CGLIB to proxy bean methods.

Fixes spring-projectsgh-6818
@rwinch rwinch added in: config An issue in spring-security-config type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 3, 2019
rwinch pushed a commit that referenced this issue Jun 3, 2019
This is so that our configuration classes do not rely on CGLIB to proxy bean methods.

Fixes gh-6818
@rwinch
Copy link
Member

rwinch commented Jun 3, 2019

Thanks for the report @sdeleuze! The changes are now merged into master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: config An issue in spring-security-config type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants