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
+267
Original file line number
Diff line number
Diff line change
@@ -212,6 +212,273 @@ companion object {
212
212
`@EnableMethodSecurity` and `<method-security>` activate stricter enforcement of Spring Security's non-repeatable or otherwise incompatible annotations.
213
213
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.
214
214
215
+
=== Use `AuthorizationManager` for Message Security
216
+
217
+
xref:servlet/integrations/websocket.adoc[Message Security] has been xref:servlet/integrations/websocket.adoc#websocket-configuration[improved] through {security-api-url}org/springframework/security/authorization/AuthorizationManager.html[the `AuthorizationManager` API] and direct use of Spring AOP.
218
+
219
+
==== Ensure all messages have defined authorization rules
220
+
221
+
The now-deprecated {security-api-url}org/springframework/security/config/annotation/web/socket/AbstractSecurityWebSocketMessageBrokerConfigurer.html[message security support] permits all messages by default.
222
+
xref:servlet/integrations/websocket.adoc[The new support] has the stronger default of denying all messages.
223
+
224
+
To prepare for this, ensure that authorization rules exist are declared for every request.
If you want to have CSRF disabled and you are using Java configuration, the migration steps are slightly different.
307
+
Instead of using `@EnableWebSocketSecurity`, you will override the appropriate methods in `WebSocketMessageBrokerConfigurer` yourself.
308
+
Please see xref:servlet/integrations/websocket.adoc#websocket-sameorigin-disable[the reference manual] for details about this step.
309
+
====
310
+
311
+
If you are using Java Configuration, add {security-api-url}org/springframework/security/config/annotation/web/socket/EnableWebSocketSecurity.html[`@EnableWebSocketSecurity`] to your application.
312
+
313
+
For example, you can add it to your websocket security configuration class, like so:
314
+
315
+
====
316
+
.Java
317
+
[source,java,role="primary"]
318
+
----
319
+
@EnableWebSocketSecurity
320
+
@Configuration
321
+
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
322
+
// ...
323
+
}
324
+
----
325
+
326
+
.Kotlin
327
+
[source,kotlin,role="secondary"]
328
+
----
329
+
@EnableWebSocketSecurity
330
+
@Configuration
331
+
class WebSocketSecurityConfig: AbstractSecurityWebSocketMessageBrokerConfigurer() {
332
+
// ...
333
+
}
334
+
----
335
+
====
336
+
337
+
This will make a prototype instance of `MessageMatcherDelegatingAuthorizationManager.Builder` available to encourage configuration by composition instead of extension.
338
+
339
+
==== Use an `AuthorizationManager<Message<?>>` instance
340
+
341
+
To start using `AuthorizationManager`, you can set the `use-authorization-manager` attribute in XML or you can publish an `AuthorizationManager<Message<?>>` `@Bean` in Java.
342
+
343
+
For example, the following application configuration:
0 commit comments