You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using org.openrewrite.java.security:OwaspTopTen recipe, it call org.openrewrite.java.security.spring.CsrfProtection recipe that use deprecated WebSecurityConfigurerAdapter Spring class.
When -Werror is activated on Java compiler, it break build.
[WARNING] /builds/src/main/java/.../SecurityConfig.java:[9,30] org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter in org.springframework.security.config.annotation.web.configuration has been deprecated
...
[ERROR] COMPILATION ERROR :
[ERROR] /builds/src/main/java/.../SecurityConfig.java: warnings found and -Werror specified
In Spring Security 5.7.0-M2 we deprecated the WebSecurityConfigurerAdapter, as we encourage users to move towards a component-based security configuration.
The text was updated successfully, but these errors were encountered:
Hi @philippe-granet thanks for reporting your concern! Am I correct in deducing that you ran OwaspTopTen, which ran CsrfProtection, which generated a fully new SecurityConfig class that uses the outdated WebSecurityConfigurerAdapter?
Did it at least correctly fix the security issue in your case?
Change the OwaspA10recipeList use of CsrfProtection to add onlyIfSecurityConfig = true.
This would for the moment at least stop it from adding outdated classes, but would like to applications without any security config not getting patched.
Follow up any iuse of GenerateWebSecurityConfigurerAdapter with org.openrewrite.java.spring.security5.WebSecurityConfigurerAdapter to upgrade the generated class to the newer version.
Some care would be needed to ensure we are at least on Spring Security 5.7+, or the configuration would not be picked up.
Alter GenerateWebSecurityConfigurerAdapter to look for and correctly insert either WebSecurityConfigurerAdapter or a SecurityConfiguration that does not extend WebSecurityConfigurerAdapter.
All of those issues would require some work. Which would suit your particular situation best?
timtebeek
changed the title
org.openrewrite.java.security.spring.CsrfProtection - Deprecated WebSecurityConfigurerAdapter
org.openrewrite.java.security.spring.CsrfProtection generates deprecated WebSecurityConfigurerAdapter
Dec 24, 2023
When using
org.openrewrite.java.security:OwaspTopTen
recipe, it callorg.openrewrite.java.security.spring.CsrfProtection
recipe that use deprecatedWebSecurityConfigurerAdapter
Spring class.When
-Werror
is activated on Java compiler, it break build.Documentation for migration: https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter/
The text was updated successfully, but these errors were encountered: