reactive.adoc 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. = Reactive
  2. If you have already performed the xref:migration/index.adoc[initial migration steps] for your Reactive application, you're now ready to perform steps specific to Reactive applications.
  3. == Use `AuthorizationManager` for Method Security
  4. In 6.0, `@EnableReactiveMethodSecurity` defaults `useAuthorizationManager` to `true`.
  5. So, to complete migration, {security-api-url}org/springframework/security/config/annotation/method/configuration/EnableReactiveMethodSecurity.html[`@EnableReactiveMethodSecurity`] remove the `useAuthorizationManager` attribute:
  6. ====
  7. .Java
  8. [source,java,role="primary"]
  9. ----
  10. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  11. ----
  12. .Kotlin
  13. [source,kotlin,role="secondary"]
  14. ----
  15. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  16. ----
  17. ====
  18. changes to:
  19. ====
  20. .Java
  21. [source,java,role="primary"]
  22. ----
  23. @EnableReactiveMethodSecurity
  24. ----
  25. .Kotlin
  26. [source,kotlin,role="secondary"]
  27. ----
  28. @EnableReactiveMethodSecurity
  29. ----
  30. ====
  31. == Propagate ``AuthenticationServiceException``s
  32. {security-api-url}org/springframework/security/web/server/authentication/AuthenticationWebFilter.html[`AuthenticationWebFilter`] propagates {security-api-url}org/springframework/security/authentication/AuthenticationServiceException.html[``AuthenticationServiceException``]s to the {security-api-url}org/springframework/security/web/server/ServerAuthenticationEntryPoint.html[`ServerAuthenticationEntryPoint`].
  33. Because ``AuthenticationServiceException``s represent a server-side error instead of a client-side error, in 6.0, this changes to propagate them to the container.
  34. So, if you opted into this behavior by setting `rethrowAuthenticationServiceException` too `true`, you can now remove it like so:
  35. ====
  36. .Java
  37. [source,java,role="primary"]
  38. ----
  39. AuthenticationFailureHandler bearerFailureHandler = new ServerAuthenticationEntryPointFailureHandler(bearerEntryPoint);
  40. bearerFailureHandler.setRethrowAuthenticationServiceException(true);
  41. AuthenticationFailureHandler basicFailureHandler = new ServerAuthenticationEntryPointFailureHandler(basicEntryPoint);
  42. basicFailureHandler.setRethrowAuthenticationServiceException(true);
  43. ----
  44. .Kotlin
  45. [source,kotlin,role="secondary"]
  46. ----
  47. val bearerFailureHandler: AuthenticationFailureHandler = ServerAuthenticationEntryPointFailureHandler(bearerEntryPoint)
  48. bearerFailureHandler.setRethrowAuthenticationServiceException(true)
  49. val basicFailureHandler: AuthenticationFailureHandler = ServerAuthenticationEntryPointFailureHandler(basicEntryPoint)
  50. basicFailureHandler.setRethrowAuthenticationServiceException(true)
  51. ----
  52. ====
  53. changes to:
  54. ====
  55. .Java
  56. [source,java,role="primary"]
  57. ----
  58. AuthenticationFailureHandler bearerFailureHandler = new ServerAuthenticationEntryPointFailureHandler(bearerEntryPoint);
  59. AuthenticationFailureHandler basicFailureHandler = new ServerAuthenticationEntryPointFailureHandler(basicEntryPoint);
  60. ----
  61. .Kotlin
  62. [source,kotlin,role="secondary"]
  63. ----
  64. val bearerFailureHandler: AuthenticationFailureHandler = ServerAuthenticationEntryPointFailureHandler(bearerEntryPoint)
  65. val basicFailureHandler: AuthenticationFailureHandler = ServerAuthenticationEntryPointFailureHandler(basicEntryPoint)
  66. ----
  67. ====
  68. [NOTE]
  69. ====
  70. If you configured the `ServerAuthenticationFailureHandler` only for the purpose of updating to 6.0, you can remove it completely.
  71. ====