migration.adoc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. In 6.0, `@EnableReactiveMethodSecurity` defaults `useAuthorizationManager` to `true`.
  15. So, to complete migration, {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableReactiveMethodSecurity.html[`@EnableReactiveMethodSecurity`] remove the `useAuthorizationManager` attribute:
  16. ====
  17. .Java
  18. [source,java,role="primary"]
  19. ----
  20. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  21. ----
  22. .Kotlin
  23. [source,kotlin,role="secondary"]
  24. ----
  25. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  26. ----
  27. ====
  28. changes to:
  29. ====
  30. .Java
  31. [source,java,role="primary"]
  32. ----
  33. @EnableReactiveMethodSecurity
  34. ----
  35. .Kotlin
  36. [source,kotlin,role="secondary"]
  37. ----
  38. @EnableReactiveMethodSecurity
  39. ----
  40. ====
  41. '''
  42. [[revert]]
  43. 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.
  44. It's more important to stay on 6.0 and get the security improvements.
  45. == Revert Servlet
  46. === Don't Use `AuthorizationManager` in Method Security
  47. To opt out of `AuthorizationManager` for Method Security, 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]
  48. 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.
  49. For example, change:
  50. ====
  51. .Java
  52. [source,java,role="primary"]
  53. ----
  54. @EnableMethodSecurity
  55. ----
  56. .Kotlin
  57. [source,kotlin,role="secondary"]
  58. ----
  59. @EnableMethodSecurity
  60. ----
  61. .Xml
  62. [source,xml,role="secondary"]
  63. ----
  64. <method-security/>
  65. ----
  66. ====
  67. to:
  68. ====
  69. .Java
  70. [source,java,role="primary"]
  71. ----
  72. @EnableGlobalMethodSecurity(prePostEnabled = true)
  73. ----
  74. .Kotlin
  75. [source,kotlin,role="secondary"]
  76. ----
  77. @EnableGlobalMethodSecurity(prePostEnabled = true)
  78. ----
  79. .Xml
  80. [source,xml,role="secondary"]
  81. ----
  82. <global-method-security pre-post-enabled="true"/>
  83. ----
  84. ====
  85. 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:
  86. ====
  87. .Java
  88. [source,java,role="primary"]
  89. ----
  90. @EnableMethodSecurity(securedEnabled = true, prePostEnabled = false)
  91. ----
  92. .Kotlin
  93. [source,kotlin,role="secondary"]
  94. ----
  95. @EnableMethodSecurity(securedEnabled = true, prePostEnabled = false)
  96. ----
  97. .Xml
  98. [source,xml,role="secondary"]
  99. ----
  100. <method-security secured-enabled="true" pre-post-enabled="false"/>
  101. ----
  102. ====
  103. should change to:
  104. ====
  105. .Java
  106. [source,java,role="primary"]
  107. ----
  108. @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = false)
  109. ----
  110. .Kotlin
  111. [source,kotlin,role="secondary"]
  112. ----
  113. @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = false)
  114. ----
  115. .Xml
  116. [source,xml,role="secondary"]
  117. ----
  118. <global-method-security secured-enabled="true" pre-post-enabled="false"/>
  119. ----
  120. ====
  121. == Revert Reactive
  122. === Don't Use `AuthorizationManager` in Method Security
  123. To opt-out of {security-api-url}org/springframework/security/authorization/AuthorizationManager.html[`AuthorizationManager`] for reactive method security, add `useAuthorizationManager = false`:
  124. ====
  125. .Java
  126. [source,java,role="primary"]
  127. ----
  128. @EnableReactiveMethodSecurity
  129. ----
  130. .Kotlin
  131. [source,kotlin,role="secondary"]
  132. ----
  133. @EnableReactiveMethodSecurity
  134. ----
  135. ====
  136. changes to:
  137. ====
  138. .Java
  139. [source,java,role="primary"]
  140. ----
  141. @EnableReactiveMethodSecurity(useAuthorizationManager = false)
  142. ----
  143. .Kotlin
  144. [source,kotlin,role="secondary"]
  145. ----
  146. @EnableReactiveMethodSecurity(useAuthorizationManager = false)
  147. ----
  148. ====