Identity.Name is always null on the client: the access token names the user in unique_name, the client reads name

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

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

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

評価

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

調査の方向性

IAuthTokenProvider.ParseAccessToken から始めてください。ここでクライアントの ClaimsPrincipal が nameType: "name" を指定して作成されているので、サーバーが書き込む claim 名(unique_name)と比較してください。名前がどのように読み取られるかは ClaimsPrincipalExtensions.GetUserName() と AuthManager.KeepActiveAccount を確認してください。サインイン済みユーザーに対してクライアント上で Identity.Name が null でなく、既存の認証テストがすべて通れば完了です。

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

説明

The server writes the access token with JwtSecurityTokenHandler, which writes ClaimTypes.Name under its short name unique_name (its DefaultOutboundClaimTypeMap). IAuthTokenProvider.ParseAccessToken builds the client's ClaimsPrincipal with nameType: "name", so on the client Identity.Name is null for every signed-in user.

The client's authentication state comes from that principal, so context.User.Identity.Name in an AuthorizeView and AuthenticationState.User.Identity.Name are null as well. In the template itself, AuthManager.KeepActiveAccount takes the kept account's UserName from it, so an account whose profile hasn't been loaded is kept with no user name. Most of the template doesn't notice, because ClaimsPrincipalExtensions.GetUserName() reads both ClaimTypes.Name and unique_name.

The parsed principal's name type should be the claim the server writes, so Identity.Name holds the user's name on the client as it does on the server.

主要言語
C#
スター
1.4k
フォーク
264
平均マージ
8時間 58分
マージ済み PR(30日)
579

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

bitfoundation/bitplatform のほかの issue

bitfoundation/bitplatform の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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