reactive.adoc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. == Validate `typ` Header with `JwtTypeValidator`
  4. If when following the 6.5 preparatory steps you set `validateTypes` to `false`, you can now remove it.
  5. You can also remove explicitly adding `JwtTypeValidator` to the list of defaults.
  6. For example, change this:
  7. [tabs]
  8. ======
  9. Java::
  10. +
  11. [source,java,role="primary"]
  12. ----
  13. @Bean
  14. JwtDecoder jwtDecoder() {
  15. NimbusReactiveJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(location)
  16. .validateTypes(false) <1>
  17. // ... your remaining configuration
  18. .build();
  19. jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithValidators(
  20. new JwtIssuerValidator(location), JwtTypeValidator.jwt())); <2>
  21. return jwtDecoder;
  22. }
  23. ----
  24. Kotlin::
  25. +
  26. [source,kotlin,role="secondary"]
  27. ----
  28. @Bean
  29. fun jwtDecoder(): JwtDecoder {
  30. val jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(location)
  31. .validateTypes(false) <1>
  32. // ... your remaining configuration
  33. .build()
  34. jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithValidators(
  35. JwtIssuerValidator(location), JwtTypeValidator.jwt())) <2>
  36. return jwtDecoder
  37. }
  38. ----
  39. ======
  40. <1> - Switch off Nimbus verifying the `typ`
  41. <2> - Add the default `typ` validator
  42. to this:
  43. [tabs]
  44. ======
  45. Java::
  46. +
  47. [source,java,role="primary"]
  48. ----
  49. @Bean
  50. NimbusReactiveJwtDecoder jwtDecoder() {
  51. NimbusJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(location)
  52. // ... your remaining configuration <1>
  53. .build();
  54. jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(location)); <2>
  55. return jwtDecoder;
  56. }
  57. ----
  58. Kotlin::
  59. +
  60. [source,kotlin,role="secondary"]
  61. ----
  62. @Bean
  63. fun jwtDecoder(): NimbusReactiveJwtDecoder {
  64. val jwtDecoder = NimbusReactiveJwtDecoder.withIssuerLocation(location)
  65. // ... your remaining configuration
  66. .build()
  67. jwtDecoder.setJwtValidator(JwtValidators.createDefaultWithIssuer(location)) <2>
  68. return jwtDecoder
  69. }
  70. ----
  71. ======
  72. <1> - `validateTypes` now defaults to `false`
  73. <2> - `JwtTypeValidator#jwt` is added by all `createDefaultXXX` methods