2
0

migration.adoc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. [[migration]]
  2. = Migrating to 6.0
  3. The Spring Security team has prepared the 5.8 release to simplify upgrading to Spring Security 6.0.
  4. Use 5.8 and its preparation steps to simplify updating to 6.0
  5. After updating to 5.8, follow this guide to perform any needed migration steps.
  6. Also, this guide includes ways to revert to 5.x behaviors and its defaults, should you run into trouble.
  7. == Updating
  8. === Reactive
  9. ==== Remove `useAuthorizationManager` usage from `@EnableReactiveMethodSecurity`
  10. {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableReactiveMethodSecurity.html[`@EnableReactiveMethodSecurity`] sets `useAuthorizationManager` to `true` by default.
  11. Because of that, in 6.0 you can change:
  12. ====
  13. .Java
  14. [source,java,role="primary"]
  15. ----
  16. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  17. ----
  18. .Kotlin
  19. [source,kotlin,role="secondary"]
  20. ----
  21. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  22. ----
  23. ====
  24. to:
  25. ====
  26. .Java
  27. [source,java,role="primary"]
  28. ----
  29. @EnableReactiveMethodSecurity
  30. ----
  31. .Kotlin
  32. [source,kotlin,role="secondary"]
  33. ----
  34. @EnableReactiveMethodSecurity
  35. ----
  36. ====
  37. == Reverting
  38. 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.
  39. It's more important to stay on 6.0 and get the security improvements.
  40. === Servlet
  41. ==== Change `@EnableMethodSecurity` to `@EnableGlobalMethodSecurity`
  42. For applications using `prePostEnabled`, make sure to turn it on to reactivate the behavior.
  43. For example, change:
  44. ====
  45. .Java
  46. [source,java,role="primary"]
  47. ----
  48. @EnableMethodSecurity
  49. ----
  50. .Kotlin
  51. [source,kotlin,role="secondary"]
  52. ----
  53. @EnableMethodSecurity
  54. ----
  55. ====
  56. to:
  57. ====
  58. .Java
  59. [source,java,role="primary"]
  60. ----
  61. @EnableGlobalMethodSecurity(prePostEnabled = true)
  62. ----
  63. .Kotlin
  64. [source,kotlin,role="secondary"]
  65. ----
  66. @EnableGlobalMethodSecurity(prePostEnabled = true)
  67. ----
  68. ====
  69. 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:
  70. ====
  71. .Java
  72. [source,java,role="primary"]
  73. ----
  74. @EnableMethodSecurity(securedEnabled = true, prePostEnabled = false)
  75. ----
  76. .Kotlin
  77. [source,kotlin,role="secondary"]
  78. ----
  79. @EnableMethodSecurity(securedEnabled = true, prePostEnabled = false)
  80. ----
  81. ====
  82. should change to:
  83. ====
  84. .Java
  85. [source,java,role="primary"]
  86. ----
  87. @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = false)
  88. ----
  89. .Kotlin
  90. [source,kotlin,role="secondary"]
  91. ----
  92. @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = false)
  93. ----
  94. ====
  95. === Reactive
  96. ==== Deactivate `AuthorizationManager` in `@EnableReactiveMethodSecurity`
  97. To opt-out of {security-api-url}org/springframework/security/authorization/AuthorizationManager.html[`AuthorizationManager`] for reactive method security, add `useAuthorizationManager = false`:
  98. ====
  99. .Java
  100. [source,java,role="primary"]
  101. ----
  102. @EnableReactiveMethodSecurity
  103. ----
  104. .Kotlin
  105. [source,kotlin,role="secondary"]
  106. ----
  107. @EnableReactiveMethodSecurity
  108. ----
  109. ====
  110. changes to:
  111. ====
  112. .Java
  113. [source,java,role="primary"]
  114. ----
  115. @EnableReactiveMethodSecurity(useAuthorizationManager = false)
  116. ----
  117. .Kotlin
  118. [source,kotlin,role="secondary"]
  119. ----
  120. @EnableReactiveMethodSecurity(useAuthorizationManager = false)
  121. ----
  122. ====