`CoreJackson2Module` has no mixin for `OneTimeTokenAuthentication`

オープン 初心者向け
#19,963 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
77/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, spring

調査の方向性

CoreJackson2ModuleをCoreJacksonModuleと併せて読み、mixinの登録を比較してから、OneTimeTokenAuthenticationTestsとJackson 2モジュールのテストを調べてください。SecurityJackson2Modulesを介したOneTimeTokenAuthenticationのシリアライズとデシリアライズをテストに追加してください。Jackson 2の往復処理がallowlistのチェックを含めて成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

status: waiting-for-triage

Describe the bug

gh-18096 added Jackson support for one-time-token authentication for 7.1, but only the Jackson 3 CoreJacksonModule registers a mixin for OneTimeTokenAuthentication; the Jackson 2 CoreJackson2Module registers one for the deprecated OneTimeTokenAuthenticationToken only. Since 7.0, OneTimeTokenAuthenticationProvider and OneTimeTokenReactiveAuthenticationManager produce OneTimeTokenAuthentication, so a SecurityContext from a one-time-token login cannot be serialized with SecurityJackson2Modules, which is still the setup of applications that keep Jackson 2 for session serialization in 7.x.

To Reproduce

ObjectMapper mapper = new ObjectMapper();
mapper.registerModules(SecurityJackson2Modules.getModules(getClass().getClassLoader()));
OneTimeTokenAuthentication authentication = new OneTimeTokenAuthentication("principal",
		AuthorityUtils.createAuthorityList("ROLE_USER"));
byte[] serialized = mapper.writeValueAsBytes(authentication);
mapper.readValue(serialized, OneTimeTokenAuthentication.class);

Deserialization fails: OneTimeTokenAuthentication is not in the allowlist and has no mixin. The same round trip with SecurityJacksonModules and a Jackson 3 JsonMapper passes (OneTimeTokenAuthenticationTests).

Expected behavior

CoreJackson2Module registers a mixin for OneTimeTokenAuthentication, like CoreJacksonModule does, so that both Jackson generations can serialize what the one-time-token login produces.

Sample

Branch with the mixin (a copy of the Jackson 3 one, deprecated for removal like the rest of jackson2) and a Jackson 2 round-trip test next to the existing Jackson 3 one: https://github.com/spring-projects/spring-security/compare/main...sharanggupta:spring-security:gh-ott-authentication-jackson2-mixin. Happy to open the PR.

主要言語
Java
スター
9.7k
フォーク
6.4k
平均マージ
1日 4時間
マージ済み PR(30日)
31

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

spring-projects/spring-security のほかの issue

spring-projects/spring-security の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。