-
Couldn't load subscription status.
- Fork 6.2k
Add Jackson 3 support and deprecate Jackson 2 one #17832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request. Generally, I think this is looking good. I've provided some feedback inline.
It also appears that there are still some classes that need migrated. Searching for jackson on main should give you a complete list of classes that are using jackson.
For example, webauthn has jackson support. I'm guessing this was missed because it is inconsistent with the rest of the jackson support in that it is in a jackson package rather than jackson2. It is also automatically registered because it does not use default types which would make it insecure.
There are also some tests that still use ObjectMapper or deprecated Spring Framework Jackson 2 classes (e.g. JwtDecodersTests.java#L388). Unless the test is specifically for the Jackson 2 support, we should update these to use non-deprecated classes (e.g. JsonMapper).
There are various Spring framework jackson based classes that have been deprecated that we should migrate away from. For example, MappingJackson2HttpMessageConverter usage (e.g. WebAuthnAuthenticationFilter.converter) should be migrated to JacksonJsonHttpMessageConverter if jackson 3 is on the classpath. Likely there could be a static factory method used that Spring Security uses to obtain the correct default json converter instance.
cas/src/main/java/org/springframework/security/cas/jackson/CasJacksonModule.java
Outdated
Show resolved
Hide resolved
...in/java/org/springframework/security/jackson/AbstractUnmodifiableCollectionDeserializer.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/springframework/security/jackson/AllowlistTypeResolverBuilder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/springframework/security/jackson/AllowlistTypeResolverBuilder.java
Outdated
Show resolved
Hide resolved
...ce-provider/src/main/java/org/springframework/security/saml2/jackson/Saml2JacksonModule.java
Outdated
Show resolved
Hide resolved
...-provider/src/main/java/org/springframework/security/saml2/jackson2/Saml2Jackson2Module.java
Show resolved
Hide resolved
|
@rwinch I have pushed additional commits:
I will do another pass with your feedback to my questions in the comments. |
e7d5c41 to
20a69ea
Compare
See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit adds support for Jackson 3 which has the following major differences with the Jackson 2 one: - jackson subpackage instead of jackson2 - Jackson type prefix instead of Jackson2 - JsonMapper instead of ObjectMapper - For configuration, JsonMapper.Builder instead of ObjectMapper since the latter is now immutable - Remove custom Jackson 3 support for unmodifiable collections - AllowlistTypeResolverBuilder in new a public type in order to be used easily with the JsonMapper.Builder API Jackson 3 changes compared to Jackson 2 are documented on FasterXML/jackson-future-ideas#72. This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
Since this module was already using the jackson sub-package for Jackson 2 support, both Jackson 2 and Jackson 3 support lives in the same subpackage and the former package-private classes has been renamed with a Jackson2 qualifier. Closes spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
|
@rwinch I have removed the custom support for unmodifiable collections (seems to work fine with Jackson 3), reworked the commit for a cleaner git history, and rebased the commits on |
See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit adds support for Jackson 3 which has the following major differences with the Jackson 2 one: - jackson subpackage instead of jackson2 - Jackson type prefix instead of Jackson2 - JsonMapper instead of ObjectMapper - For configuration, JsonMapper.Builder instead of ObjectMapper since the latter is now immutable - Remove custom Jackson 3 support for unmodifiable collections - AllowlistTypeResolverBuilder in new a public type in order to be used easily with the JsonMapper.Builder API Jackson 3 changes compared to Jackson 2 are documented on FasterXML/jackson-future-ideas#72. This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
Since this module was already using the jackson sub-package for Jackson 2 support, both Jackson 2 and Jackson 3 support lives in the same subpackage and the former package-private classes has been renamed with a Jackson2 qualifier. Closes spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
|
@sdeleuze @rwinch I was wondering if message converters in Lines 41 to 47 in f3761af
That's then causing NPE's i.e in |
Since this module was already using the jackson sub-package for Jackson 2 support, both Jackson 2 and Jackson 3 support lives in the same subpackage and the former package-private classes has been renamed with a Jackson2 qualifier. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commits remove global default typing for better security and use instead a custom PolymorphicTypeValidator. See https://cowtowncoder.medium.com/jackson-2-10-safe-default-typing-2d018f0ce2ba for more details. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
|
@jvalkeal Good catch, I will add a related commit. |
See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit adds support for Jackson 3 which has the following major differences with the Jackson 2 one: - jackson subpackage instead of jackson2 - Jackson type prefix instead of Jackson2 - JsonMapper instead of ObjectMapper - For configuration, JsonMapper.Builder instead of ObjectMapper since the latter is now immutable - Remove custom Jackson 3 support for unmodifiable collections - AllowlistTypeResolverBuilder in new a public type in order to be used easily with the JsonMapper.Builder API Jackson 3 changes compared to Jackson 2 are documented on FasterXML/jackson-future-ideas#72. This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
Since this module was already using the jackson sub-package for Jackson 2 support, both Jackson 2 and Jackson 3 support lives in the same subpackage and the former package-private classes has been renamed with a Jackson2 qualifier. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commits remove global default typing for better security and use instead a custom PolymorphicTypeValidator which can be configured by each Spring Security module and customized by the end users. See https://cowtowncoder.medium.com/jackson-2-10-safe-default-typing-2d018f0ce2ba for more details. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit introduces classpath checks and instantiation of JacksonJsonHttpMessageConverter (based on Jackson 3) leveraging a new GenericHttpMessageConverterAdapter which allows to adapt SmartHttpMessageConverter to GenericHttpMessageConverter. Closes spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
Signed-off-by: Sébastien Deleuze <[email protected]>
See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit adds support for Jackson 3 which has the following major differences with the Jackson 2 one: - jackson subpackage instead of jackson2 - Jackson type prefix instead of Jackson2 - JsonMapper instead of ObjectMapper - For configuration, JsonMapper.Builder instead of ObjectMapper since the latter is now immutable - Remove custom support for unmodifiable collections - Use safe default typing via a PolymorphicTypeValidator Jackson 3 changes compared to Jackson 2 are documented in https://cowtowncoder.medium.com/jackson-3-0-0-ga-released-1f669cda529a and https://github.com/FasterXML/jackson/blob/main/jackson3/MIGRATING_TO_JACKSON_3.md. This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
Since this module was already using the jackson sub-package for Jackson 2 support, both Jackson 2 and Jackson 3 support lives in the same subpackage and the former package-private classes has been renamed with a Jackson2 qualifier. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit introduces classpath checks and instantiation of JacksonJsonHttpMessageConverter (based on Jackson 3) leveraging a new GenericHttpMessageConverterAdapter which allows to adapt SmartHttpMessageConverter to GenericHttpMessageConverter. See spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit refines the documentation by: - Updating Jackson documentation for Jackson 3 - Removing the outdated documentation in servlet - Adding migration guidelines Closes spring-projectsgh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
Without this many of the tests fail when using Jackson 3
- We should not introduce an unnecessary public API
- It would need to be removed when Jackson 2 support was removed, but
was required to configure Jackson 3 support
- There are already existing interfaces that could be used
- OAuth2AuthorizationRowMapper & OAuth2AuthorizationParametersMapper had
unnecessary breaking changes by removing getter/setter for ObjectMapper
- To prevent NoClassDefFoundErrors all optional (Jackson) dependencies
need to be on different classes & we wish to preserve the existing
accessors for ObjectMapper which is this uses subclasses
- With added TestAuthenticationTokenMixin support, no need to explicitly
add it in tests
…eConverter) This makes sense given that Framework's new Jackson support is a SmartHttpMessageConverter. Additionally, GenericHttpMessageConverterAdapter is now package private to encapsulate it. Issue spring-projectsgh-18073
This will allow its removal in spring-projectsgh-18073
See gh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit adds support for Jackson 3 which has the following major differences with the Jackson 2 one: - jackson subpackage instead of jackson2 - Jackson type prefix instead of Jackson2 - JsonMapper instead of ObjectMapper - For configuration, JsonMapper.Builder instead of ObjectMapper since the latter is now immutable - Remove custom support for unmodifiable collections - Use safe default typing via a PolymorphicTypeValidator Jackson 3 changes compared to Jackson 2 are documented in https://cowtowncoder.medium.com/jackson-3-0-0-ga-released-1f669cda529a and https://github.com/FasterXML/jackson/blob/main/jackson3/MIGRATING_TO_JACKSON_3.md. This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See gh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit does not cover webauthn which is a special case (uses jackson sub-package for Jackson 2 support) which will be handled in a distinct commit. See gh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
Since this module was already using the jackson sub-package for Jackson 2 support, both Jackson 2 and Jackson 3 support lives in the same subpackage and the former package-private classes has been renamed with a Jackson2 qualifier. See gh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit introduces classpath checks and instantiation of JacksonJsonHttpMessageConverter (based on Jackson 3) leveraging a new GenericHttpMessageConverterAdapter which allows to adapt SmartHttpMessageConverter to GenericHttpMessageConverter. See gh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
This commit refines the documentation by: - Updating Jackson documentation for Jackson 3 - Removing the outdated documentation in servlet - Adding migration guidelines Closes gh-17832 Signed-off-by: Sébastien Deleuze <[email protected]>
|
Thank you for all of your hard work on this @sdeleuze This, along with some changes, have been merged into main. You can see the commits on this PR for details around the changes that were applied. I've also created some tickets to resolve some remaining issues: |
This PR adds support for Jackson 3 which has the following major differences with the Jackson 2 one:
jacksonsubpackage instead ofjackson2Jacksontype prefix instead ofJackson2JsonMapperinstead ofObjectMapperJsonMapper.Builderinstead ofObjectMappersince the latter is now immutableAllowlistTypeResolverBuilderin new a public type in order to be used easily with theJsonMapper.BuilderAPIJackson 3 changes compared to Jackson 2 are documented on FasterXML/jackson-future-ideas#72.
It also deprecates Jackson 2 support for removal.