Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jonsage opened this issue Apr 26, 2023 · 0 comments

Comments

@jonsage
Copy link

jonsage commented Apr 26, 2023

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

On Line 339 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:

// getSubject returns a unique identify suitable for the subject field
function getSubject(decodedToken) {
	return decodedToken.payload.email || decodedToken.payload.unique_name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant