2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

dotnet8でjwt認証に失敗する件について

Posted at

dotnet8のwebapiアプリでjwt認証に失敗する

このパッケージを追加したら解決しました
Microsoft.IdentityModel.JsonWebTokens 7.5.1

以下、調査記録

トークン検証エラーが、、

image.png

ログ確認

AppSettings.jsonのログレベル変更してみる

  • Microsoft.*をLogLevelに追加
    image.png

  • IDX14100のエラーが、、
    image.png
    ※ JWTはきちんと"."で区切られた文字列でした

ぐぐる

以下のIssueにたどり着く
.NET 8 behaves differently for JwtBearerOptions in AddJwtBearer

image.png

皆さんこんにちは。追加して問題を修正しました
<PacageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.4.1" />

Issueによるとdotnet8で破壊的変更が加わったとのこと

ついでに破壊的変更の内容をみてみる

ありがたいことに以下の日本語公式ページがありました
「その中にセキュリティトークンイベントがJsonWebTokenを返す」の記載が
.NET 8 の破壊的変更
image.png

セキュリティ トークン イベントが JsonWebToken を返す

TokenValidatedContext.SecurityToken の既定の実際の実装が JwtSecurityToken から JsonWebToken に変更されました。

JsonWebTokenのdllがないからトークンの解析に失敗してたんでしょうか、、

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?