123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- [[migration]]
- = Migrating to 6.0
- The Spring Security team has prepared the 5.8 release to simplify upgrading to Spring Security 6.0.
- Use 5.8 and its preparation steps to simplify updating to 6.0
- After updating to 5.8, follow this guide to perform any needed migration steps.
- Also, this guide includes ways to revert to 5.x behaviors and its defaults, should you run into trouble.
- == Updating
- === Reactive
- ==== Remove `useAuthorizationManager` usage from `@EnableReactiveMethodSecurity`
- {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableReactiveMethodSecurity.html[`@EnableReactiveMethodSecurity`] sets `useAuthorizationManager` to `true` by default.
- Because of that, in 6.0 you can change:
- ====
- .Java
- [source,java,role="primary"]
- ----
- @EnableReactiveMethodSecurity(useAuthorizationManager = true)
- ----
- .Kotlin
- [source,kotlin,role="secondary"]
- ----
- @EnableReactiveMethodSecurity(useAuthorizationManager = true)
- ----
- ====
- to:
- ====
- .Java
- [source,java,role="primary"]
- ----
- @EnableReactiveMethodSecurity
- ----
- .Kotlin
- [source,kotlin,role="secondary"]
- ----
- @EnableReactiveMethodSecurity
- ----
- ====
- == Reverting
- If you are running into trouble with any of the 6.0 changes, please first try to apply the following changes to get you up and running.
- It's more important to stay on 6.0 and get the security improvements.
- === Servlet
- ==== Change `@EnableMethodSecurity` to `@EnableGlobalMethodSecurity`
- For applications using `prePostEnabled`, make sure to turn it on to reactivate the behavior.
- For example, change:
- ====
- .Java
- [source,java,role="primary"]
- ----
- @EnableMethodSecurity
- ----
- .Kotlin
- [source,kotlin,role="secondary"]
- ----
- @EnableMethodSecurity
- ----
- ====
- to:
- ====
- .Java
- [source,java,role="primary"]
- ----
- @EnableGlobalMethodSecurity(prePostEnabled = true)
- ----
- .Kotlin
- [source,kotlin,role="secondary"]
- ----
- @EnableGlobalMethodSecurity(prePostEnabled = true)
- ----
- ====
- Other usage can simply change {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableMethodSecurity.html[`@EnableMethodSecurity`] to {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableGlobalMethodSecurity.html[`@EnableGlobalMethodSecurity`], like so:
- ====
- .Java
- [source,java,role="primary"]
- ----
- @EnableMethodSecurity(securedEnabled = true, prePostEnabled = false)
- ----
- .Kotlin
- [source,kotlin,role="secondary"]
- ----
- @EnableMethodSecurity(securedEnabled = true, prePostEnabled = false)
- ----
- ====
- should change to:
- ====
- .Java
- [source,java,role="primary"]
- ----
- @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = false)
- ----
- .Kotlin
- [source,kotlin,role="secondary"]
- ----
- @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = false)
- ----
- ====
- === Reactive
- ==== Deactivate `AuthorizationManager` in `@EnableReactiveMethodSecurity`
- To opt-out of {security-api-url}org/springframework/security/authorization/AuthorizationManager.html[`AuthorizationManager`] for reactive method security, add `useAuthorizationManager = false`:
- ====
- .Java
- [source,java,role="primary"]
- ----
- @EnableReactiveMethodSecurity
- ----
- .Kotlin
- [source,kotlin,role="secondary"]
- ----
- @EnableReactiveMethodSecurity
- ----
- ====
- changes to:
- ====
- .Java
- [source,java,role="primary"]
- ----
- @EnableReactiveMethodSecurity(useAuthorizationManager = false)
- ----
- .Kotlin
- [source,kotlin,role="secondary"]
- ----
- @EnableReactiveMethodSecurity(useAuthorizationManager = false)
- ----
- ====
|