You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/migration.adoc
+81-24Lines changed: 81 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,18 @@ Use 5.8 and the steps below to minimize changes when updating to 6.0.
6
6
7
7
== Servlet
8
8
9
-
=== Change `@EnableGlobalMethodSecurity` to `@EnableMethodSecurity`
9
+
=== Use `AuthorizationManager` for Method Security
10
10
11
11
xref:servlet/authorization/method-security.adoc[Method Security] has been xref:servlet/authorization/method-security.adoc#jc-enable-method-security[simplified] through {security-api-url}org/springframework/security/authorization/AuthorizationManager.html[the `AuthorizationManager` API] and direct use of Spring AOP.
12
12
13
-
The public API difference between these two annotations is that {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableMethodSecurity.html[`@EnableMethodSecurity`] defaults `prePostEnabled` to `true`, while {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableGlobalMethodSecurity.html[`@EnableGlobalMethodSecurity`] defaults it to `false`.
14
-
Also, `@EnableMethodSecurity` internally uses `AuthorizationManager` while `@EnableGlobalMethodSecurity` does not.
* [ ] Replace xref:servlet/authorization/method-security.adoc#jc-enable-global-method-security[global method security] with xref:servlet/authorization/method-security.adoc#jc-enable-method-security[method security]
18
+
19
+
{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>`] are deprecated in favor of {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>`], respectively.
20
+
The new annotation and XML element activate Spring's xref:servlet/authorization/method-security.adoc#jc-enable-method-security[pre-post annotations] by default and use `AuthorizationManager` internally.
15
21
16
22
This means that the following two listings are functionally equivalent:
17
23
@@ -27,9 +33,15 @@ This means that the following two listings are functionally equivalent:
Additionally, note that `@EnableMethodSecurity` activates stricter enforcement of Spring Security's non-repeatable or otherwise incompatible annotations.
83
-
If after moving to `@EnableMethodSecurity` you see ``AnnotationConfigurationException``s in your logs, follow the instructions in the exception message to clean up your application's method security annotation usage.
112
+
'''
84
113
85
-
==== Publish your custom `PermissionEvaluator` as a `MethodSecurityExpressionHandler`
* [ ] Publish a `MethodSecurityExpressionHandler` instead of a `PermissionEvaluator`
86
117
87
-
`@EnableMethodSecurity` does not pick up a `PermissionEvaluator` bean.
88
-
Instead, it picks up the more generic `MethodSecurityExpressionHandler` to simplify the API.
118
+
`@EnableMethodSecurity` does not pick up a `PermissionEvaluator`.
119
+
This helps keep its API simple.
89
120
90
121
If you have a custom {security-api-url}org/springframework/security/access/PermissionEvaluator.html[`PermissionEvaluator`] `@Bean`, please change it from:
91
122
@@ -94,17 +125,19 @@ If you have a custom {security-api-url}org/springframework/security/access/Permi
* [ ] Check for ``AnnotationConfigurationException``s
178
+
179
+
`@EnableMethodSecurity` and `<method-security>` activate stricter enforcement of Spring Security's non-repeatable or otherwise incompatible annotations.
180
+
If after moving to either you see ``AnnotationConfigurationException``s in your logs, follow the instructions in the exception message to clean up your application's method security annotation usage.
181
+
138
182
== Reactive
139
183
140
-
=== Activate `AuthorizationManager` in `@EnableReactiveMethodSecurity`
184
+
=== Use `AuthorizationManager` for Method Security
141
185
142
186
xref:reactive/authorization/method.adoc[Method Security] has been xref:reactive/authorization/method.adoc#jc-enable-reactive-method-security-authorization-manager[improved] through {security-api-url}org/springframework/security/authorization/AuthorizationManager.html[the `AuthorizationManager` API] and direct use of Spring AOP.
143
187
188
+
'''
189
+
190
+
[[reactive-change-to-useauthorizationmanager]]
191
+
[%interactive]
192
+
* [ ] Change `useAuthorizationManager` to `true`
193
+
144
194
In Spring Security 5.8, `useAuthorizationManager` was added to {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableReactiveMethodSecurity.html[`@EnableReactiveMethodSecurity`] to allow applications to opt-in to ``AuthorizationManager``'s features.
145
195
146
196
To opt in, change `useAuthorizationManager` to `true` like so:
@@ -175,9 +225,16 @@ changes to:
175
225
----
176
226
====
177
227
178
-
Note that in 6.0, `useAuthorizationManager` defaults to `true`.
228
+
[NOTE]
229
+
=====
230
+
In 6.0, `useAuthorizationManager` defaults to `true`.
231
+
=====
179
232
180
-
Additionally, note that `useAuthorizationManager` activates stricter enforcement of Spring Security's non-repeatable or otherwise incompatible annotations.
181
-
If after turning on `useAuthorizationManager` you see ``AnnotationConfigurationException``s in your logs, follow the instructions in the exception message to clean up your application's method security annotation usage.
* [ ] Check for ``AnnotationConfigurationException``s
183
238
239
+
`useAuthorizationManager` activates stricter enforcement of Spring Security's non-repeatable or otherwise incompatible annotations.
240
+
If after turning on `useAuthorizationManager` you see ``AnnotationConfigurationException``s in your logs, follow the instructions in the exception message to clean up your application's method security annotation usage.
0 commit comments