2
0

reactive.adoc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. [tabs]
  7. ======
  8. Java::
  9. +
  10. [source,java,role="primary"]
  11. ----
  12. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  13. ----
  14. Kotlin::
  15. +
  16. [source,kotlin,role="secondary"]
  17. ----
  18. @EnableReactiveMethodSecurity(useAuthorizationManager = true)
  19. ----
  20. ======
  21. changes to:
  22. [tabs]
  23. ======
  24. Java::
  25. +
  26. [source,java,role="primary"]
  27. ----
  28. @EnableReactiveMethodSecurity
  29. ----
  30. Kotlin::
  31. +
  32. [source,kotlin,role="secondary"]
  33. ----
  34. @EnableReactiveMethodSecurity
  35. ----
  36. ======
  37. == Propagate ``AuthenticationServiceException``s
  38. {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`].
  39. 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.
  40. So, if you opted into this behavior by setting `rethrowAuthenticationServiceException` too `true`, you can now remove it like so:
  41. [tabs]
  42. ======
  43. Java::
  44. +
  45. [source,java,role="primary"]
  46. ----
  47. AuthenticationFailureHandler bearerFailureHandler = new ServerAuthenticationEntryPointFailureHandler(bearerEntryPoint);
  48. bearerFailureHandler.setRethrowAuthenticationServiceException(true);
  49. AuthenticationFailureHandler basicFailureHandler = new ServerAuthenticationEntryPointFailureHandler(basicEntryPoint);
  50. basicFailureHandler.setRethrowAuthenticationServiceException(true);
  51. ----
  52. Kotlin::
  53. +
  54. [source,kotlin,role="secondary"]
  55. ----
  56. val bearerFailureHandler: AuthenticationFailureHandler = ServerAuthenticationEntryPointFailureHandler(bearerEntryPoint)
  57. bearerFailureHandler.setRethrowAuthenticationServiceException(true)
  58. val basicFailureHandler: AuthenticationFailureHandler = ServerAuthenticationEntryPointFailureHandler(basicEntryPoint)
  59. basicFailureHandler.setRethrowAuthenticationServiceException(true)
  60. ----
  61. ======
  62. changes to:
  63. [tabs]
  64. ======
  65. Java::
  66. +
  67. [source,java,role="primary"]
  68. ----
  69. AuthenticationFailureHandler bearerFailureHandler = new ServerAuthenticationEntryPointFailureHandler(bearerEntryPoint);
  70. AuthenticationFailureHandler basicFailureHandler = new ServerAuthenticationEntryPointFailureHandler(basicEntryPoint);
  71. ----
  72. Kotlin::
  73. +
  74. [source,kotlin,role="secondary"]
  75. ----
  76. val bearerFailureHandler: AuthenticationFailureHandler = ServerAuthenticationEntryPointFailureHandler(bearerEntryPoint)
  77. val basicFailureHandler: AuthenticationFailureHandler = ServerAuthenticationEntryPointFailureHandler(basicEntryPoint)
  78. ----
  79. ======
  80. [NOTE]
  81. ====
  82. If you configured the `ServerAuthenticationFailureHandler` only for the purpose of updating to 6.0, you can remove it completely.
  83. ====