migration.adoc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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,revert to 5.x>> behaviors and its defaults, should you run into trouble.
  7. == Servlet
  8. === Use `AuthorizationManager` for Method Security
  9. There are no further migration steps for this feature.
  10. However, if you run into trouble with this enhancement, you can instead <<servlet-replace-methodsecurity-with-globalmethodsecurity,revert the behavior>>.
  11. == Reactive
  12. === Use `AuthorizationManager` for Method Security
  13. If you run into trouble with this enhancement, you can instead <<reactive-change-to-useauthorizationmanager-false,revert the behavior>>.
  14. [[reactive-method-security-remove-useauthorizationmanager]]
  15. [%interactive]
  16. * [ ] Remove `useAuthorizationManager` usage from `@EnableReactiveMethodSecurity`
  17. {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableReactiveMethodSecurity.html[`@EnableReactiveMethodSecurity`] sets `useAuthorizationManager` to `true` by default.
  18. Because of that, in 6.0 you can change:
  19. ====
  20. .Java
  21. [source,java,role="primary"]
  22. ----
  23. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  24. ----
  25. .Kotlin
  26. [source,kotlin,role="secondary"]
  27. ----
  28. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  29. ----
  30. ====
  31. to:
  32. ====
  33. .Java
  34. [source,java,role="primary"]
  35. ----
  36. @EnableReactiveMethodSecurity
  37. ----
  38. .Kotlin
  39. [source,kotlin,role="secondary"]
  40. ----
  41. @EnableReactiveMethodSecurity
  42. ----
  43. ====
  44. '''
  45. [[revert]]
  46. 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.
  47. It's more important to stay on 6.0 and get the security improvements.
  48. == Revert Servlet
  49. === Don't Use `AuthorizationManager` in Method Security
  50. [[servlet-replace-methodsecurity-with-globalmethodsecurity]]
  51. [%interactive]
  52. * [ ] Replace xref:servlet/authorization/method-security.adoc#jc-enable-method-security[method security] with xref:servlet/authorization/method-security.adoc#jc-enable-global-method-security[global method security]
  53. For applications using xref:servlet/authorization/method-security.adoc#jc-enable-method-security[pre-post annotations], make sure to turn it on to reactivate the behavior.
  54. For example, change:
  55. ====
  56. .Java
  57. [source,java,role="primary"]
  58. ----
  59. @EnableMethodSecurity
  60. ----
  61. .Kotlin
  62. [source,kotlin,role="secondary"]
  63. ----
  64. @EnableMethodSecurity
  65. ----
  66. .Xml
  67. [source,xml,role="secondary"]
  68. ----
  69. <method-security/>
  70. ----
  71. ====
  72. to:
  73. ====
  74. .Java
  75. [source,java,role="primary"]
  76. ----
  77. @EnableGlobalMethodSecurity(prePostEnabled = true)
  78. ----
  79. .Kotlin
  80. [source,kotlin,role="secondary"]
  81. ----
  82. @EnableGlobalMethodSecurity(prePostEnabled = true)
  83. ----
  84. .Xml
  85. [source,xml,role="secondary"]
  86. ----
  87. <global-method-security pre-post-enabled="true"/>
  88. ----
  89. ====
  90. Other usages can simply change {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableMethodSecurity.html[`@EnableMethodSecurity`] and xref:servlet/appendix/namespace/method-security.adoc#nsa-method-security[`<method-security>`] to {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableGlobalMethodSecurity.html[`@EnableGlobalMethodSecurity`] and xref:servlet/appendix/namespace/method-security.adoc#nsa-global-method-security[`<global-method-security>`], like so:
  91. ====
  92. .Java
  93. [source,java,role="primary"]
  94. ----
  95. @EnableMethodSecurity(securedEnabled = true, prePostEnabled = false)
  96. ----
  97. .Kotlin
  98. [source,kotlin,role="secondary"]
  99. ----
  100. @EnableMethodSecurity(securedEnabled = true, prePostEnabled = false)
  101. ----
  102. .Xml
  103. [source,xml,role="secondary"]
  104. ----
  105. <method-security secured-enabled="true" pre-post-enabled="false"/>
  106. ----
  107. ====
  108. should change to:
  109. ====
  110. .Java
  111. [source,java,role="primary"]
  112. ----
  113. @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = false)
  114. ----
  115. .Kotlin
  116. [source,kotlin,role="secondary"]
  117. ----
  118. @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = false)
  119. ----
  120. .Xml
  121. [source,xml,role="secondary"]
  122. ----
  123. <global-method-security secured-enabled="true" pre-post-enabled="false"/>
  124. ----
  125. ====
  126. == Revert Reactive
  127. === Don't Use `AuthorizationManager` in Method Security
  128. [[reactive-change-to-useauthorizationmanager-false]]
  129. [%interactive]
  130. * [ ] Change `useAuthorizationManager` to `false`
  131. To opt-out of {security-api-url}org/springframework/security/authorization/AuthorizationManager.html[`AuthorizationManager`] for reactive method security, add `useAuthorizationManager = false`:
  132. ====
  133. .Java
  134. [source,java,role="primary"]
  135. ----
  136. @EnableReactiveMethodSecurity
  137. ----
  138. .Kotlin
  139. [source,kotlin,role="secondary"]
  140. ----
  141. @EnableReactiveMethodSecurity
  142. ----
  143. ====
  144. changes to:
  145. ====
  146. .Java
  147. [source,java,role="primary"]
  148. ----
  149. @EnableReactiveMethodSecurity(useAuthorizationManager = false)
  150. ----
  151. .Kotlin
  152. [source,kotlin,role="secondary"]
  153. ----
  154. @EnableReactiveMethodSecurity(useAuthorizationManager = false)
  155. ----
  156. ====