-
Notifications
You must be signed in to change notification settings - Fork 38
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
33 improve id token extraction and validation #34
33 improve id token extraction and validation #34
Conversation
* Removes use of the 'upn' claim for email addresses, since if an 'email' claim is not provided, the user's email is not verified * Uses the combination of 'tid' and 'oid' as a uuid, since 'oid' is only unique within a single-tenant * Adds validation of 'aud', 'iss', 'nbf' and 'exp' id token claims Ref RIPAGlobal#33
I'll have to get to this properly next week but didn't want to leave you in suspense until then. I'll get the questions answered then too. At a glance, the bones of the PR look great and I'm especially happy to see the URLs for relevant documentation in comments. I love that. Thanks for the work here. I'm pretty sure we will be able to get this through next week; fingers crossed! |
NB, on question (1): I do note the commentary for And having only just said I'd look more into this next week, I can also answer (2) - #19. I don't think (3) is a question so much as an explanation, and there are already comments in your new implementation to explain that; it seems fine. |
@pond Thanks for the initial feedback. Regarding (1) in my case at least the 'upn' came from the auth_token when I tested and was not in the ID token, but the commit message that added the merge indeed seems to indicate there's more relevant information to be found in the auth_token. However, I don't know if (1) the same information cannot be found in the id_token, if the proper claims are specified in the 'app registration' configuration in the azure portal and (2) if the 'auth_token' may also contain an email claim, and if so, whether this claim is also scrubbed from the auth token if the email is not validated. If this is not the case, it's a potential risk. Since from my experience Microsoft docs generally cannot be trusted to be complete or correct, I wonder if we can find this out somehow... Looking forward to your feedback later. |
OK, going with a V3 option with renamed gem. On Upgrade guide is going to say this about UIDs:
|
EDIT: Text below kept for context, but this just turns out to be because the issuer validation code was checking EDITED EDIT: Fixed in 16c55b0. @tom-brouwer-bex The PR for v3 at #37 is sufficiently advanced that I decided to test it for real with our own AD integration, so branched our large main app, updated things per the upgrading guide and tried to log in. This fails, because of the new JWT validation:
I've tested this, and the tenant ID being used there is that of the MS Entra tenanted user who is logging in. That means in order to validate the JWT, the tenant ID needs to be known in advance. Our application is multi-(our)-tenant, which means in turn that one of our tenants, choosing to sign in using Entra, will have an issuer value that we simply cannot know and cannot possibly specify using the For this reason, either that part of validation needs to be removed, or become optional (which could be complex for people). Do you have an opinions or suggestions here? Thanks. |
@pond Your change looks good. Indeed the code was meant to only validate the issuer for single-tenant apps, because only then you know what tenant-id to expect. I overlooked the part where options.tenant_id was set to 'common' if it was not provided. |
Possible solution to solve #33
It:
Notes/Questions:
Note that this should still be operationally tested with both single-tenant and multi-tenant applications