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

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

Đang mở
#51 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
73
Fork
22
Merge trung bình
19 giờ 45 phút
Pull request đã merge (30 ngày)
1

Mô tả

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;
}
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu tại src/js/auth.js ở dòng 339 và theo dõi cách decodedToken.payload.email được sử dụng khi tạo subject của JWT đã ký. So sánh các claims Microsoft AD/OIDC hiện có được nêu trong issue, sau đó xác định và xác minh hành vi đối với các provider có và không có email; hoàn tất khi flow không còn trả về lỗi 500 không được giải thích đối với cấu hình đã được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
authentication
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.