aws-samples / aws-samples/lambdaedge-openidconnect-samples

The `subject` field used in the JWT causes unknown error when using Microsoft AD / OIDC

オープン
#51 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
73
フォーク
22
平均マージ
19時間 45分
マージ済み PR(30日)
1

説明

Microsoft AD/OIDC will not return the `email` claim even if the email scope is requested.

On [Line 339](https://github.com/aws-samples/lambdaedge-openidconnect-samples/blob/b4131275945f8ab0f6f4433b199950575db7c8fc/src/js/auth.js#L339) the cookie is set with a signed JSON Web Token containing a `subject` field that requires `decodedToken.payload.email`, however when that `email` claim is not present the code 500 errors with no details.

Switching to `decodedToken.payload.unique_name` fixes the problem when using Microsoft AD - however whether this is a breaking change for other providers I don't know.

I would like to see a more dynamic why to get the subject for the JWT, or at least extra documentation pointing out this potential issue.

In my code I have replaced any `decodedToken.payload.email` with `getSubject(decodedToken)` and added the following function to the bottom of my `auth.js` file:

```javascript
// getSubject returns a unique identify suitable for the subject field
function getSubject(decodedToken) {
return decodedToken.payload.email || decodedToken.payload.unique_name;
}
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/js/auth.js の 339 行目から開始し、署名付き JWT の subject を作成するときに decodedToken.payload.email がどのように使用されるかを追跡します。issue に示されている利用可能な Microsoft AD/OIDC claims を比較し、email があるプロバイダーとないプロバイダーの動作を定義して検証します。報告された構成でフローが説明のない 500 を返さなくなれば完了です。

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

評価

技術スタック
javascript
領域
authentication
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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