Migrate to Spring Security 5.8
Recipe ID
org.openrewrite.java.spring.security5.UpgradeSpringSecurity_5_8Artifactorg.openrewrite.recipe:rewrite-springMigrate applications to the latest Spring Security 5.8 release. This recipe will modify an application's build files, make changes to deprecated/preferred APIs, and migrate configuration settings that have changes between versions.
Composite recipespringsecurityMSAL
Add to your build
Get a download tokenThis recipe is Moderne licensed, so the token must belong to a Moderne customer. It replaces YOUR_DOWNLOAD_TOKEN below.
~/.gradle/gradle.properties
codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN
build.gradle.kts
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("org.openrewrite.java.spring.security5.UpgradeSpringSecurity_5_8")
}
repositories {
mavenCentral()
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = providers.gradleProperty("codeGenomeUsername").get()
password = providers.gradleProperty("codeGenomeToken").get()
}
}
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-spring:6.40.0")
}
Then run
./gradlew rewriteRunUsage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.java.spring.security5.UpgradeSpringSecurity_5_8If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-spring:RELEASEDefinition
This recipe runs the following recipes in order.
- Migrate to Spring Security 5.7
org.openrewrite.java.spring.security5.UpgradeSpringSecurity_5_7 - Upgrade Gradle or Maven dependency versions
org.openrewrite.java.dependencies.UpgradeDependencyVersion - Upgrade Gradle or Maven dependency versions
org.openrewrite.java.dependencies.UpgradeDependencyVersion - Convert
HttpSecuritychained calls into Lambda DSLorg.openrewrite.java.spring.boot2.HttpSecurityLambdaDsl - Convert
ServerHttpSecuritychained calls into Lambda DSLorg.openrewrite.java.spring.boot2.ServerHttpSecurityLambdaDsl - Convert
HeadersConfigurerchained calls into Lambda DSLorg.openrewrite.java.spring.boot2.HeadersConfigurerLambdaDsl - Replace
HttpSecurity.authorizeRequests(...)withHttpSecurity.authorizeHttpRequests(...)andExpressionUrlAuthorizationConfigurer,AbstractInterceptUrlConfigurerwithAuthorizeHttpRequestsConfigurer, etcorg.openrewrite.java.spring.security5.AuthorizeHttpRequests - Convert
requestMatcherschain tosecurityMatcherorg.openrewrite.java.spring.security5.ConvertSecurityMatchersToSecurityMatcher - Use the new
requestMatchersmethodsorg.openrewrite.java.spring.security5.UseNewRequestMatchers - Use the new
securityMatcher()methodorg.openrewrite.java.spring.security5.UseNewSecurityMatchers - Use new
Pbkdf2PasswordEncoderfactory methodsorg.openrewrite.java.spring.security5.UpdatePbkdf2PasswordEncoder - Use new
SCryptPasswordEncoderfactory methodsorg.openrewrite.java.spring.security5.UpdateSCryptPasswordEncoder - Use new
Argon2PasswordEncoderfactory methodsorg.openrewrite.java.spring.security5.UpdateArgon2PasswordEncoder - Rename the package name from
com.nimbusds.jose.shaded.jsontonet.minidev.jsonorg.openrewrite.java.spring.security5.RenameNimbusdsJsonObjectPackageName - Replace global method security with method security
org.openrewrite.java.spring.security5.ReplaceGlobalMethodSecurityWithMethodSecurity - Replace global method security with method security
org.openrewrite.java.spring.security5.ReplaceGlobalMethodSecurityWithMethodSecurityXml
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats