-
Notifications
You must be signed in to change notification settings - Fork 969
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
feat: extend Microsoft Graph API capabilities #3609
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #3609 +/- ##
==========================================
- Coverage 78.31% 78.29% -0.03%
==========================================
Files 346 346
Lines 23571 23575 +4
==========================================
- Hits 18460 18458 -2
- Misses 3717 3720 +3
- Partials 1394 1397 +3 ☔ View full report in Codecov by Sentry. |
Included the change in the docs ory/docs#1603 |
Is there a way to make this possible without having to add configuration? Is the set of user attributes fixed at microsoft? In that case, we could always request all of them in put them into |
To my understanding, Graph API exceeds beyond standard OIDC fields, the scope is literally entire User.Read permission in Azure cloud. It returns basically every attribute a Microsoft user account can have. This SO answer sums it up - each and every field has to be explicitly given (and by default, without Microsoft Provider already makes an exception to the config by introducing With my fork I managed to successfully get users' departments and use them with Keto for resource access, so that is one niche use achieved. Answering the questions:
Yes and no. You can hardcode the URL with every property like so: "https://graph.microsoft.com/v1.0/me?$select=aboutMe,accountEnabled,ageGroup,assignedLicenses,assignedPlans,birthday,businessPhones,city,companyName,consentProvidedForMinor,country,createdDateTime,creationType,customSecurityAttributes,deletedDateTime,department,displayName,employeeHireDate,employeeLeaveDateTime,employeeId,employeeOrgData,employeeType,externalUserState,externalUserStateChangeDateTime,faxNumber,givenName,hireDate,id,identities,imAddresses,interests,isResourceAccount,jobTitle,lastPasswordChangeDateTime,legalAgeGroupClassification,licenseAssignmentStates,mail,mailboxSettings,mailNickname,mobilePhone,mySite,officeLocation,onPremisesDistinguishedName,onPremisesDomainName,onPremisesExtensionAttributes,onPremisesImmutableId,onPremisesLastSyncDateTime,onPremisesProvisioningErrors,onPremisesSamAccountName,onPremisesSecurityIdentifier,onPremisesSyncEnabled,onPremisesUserPrincipalName,otherMails,passwordPolicies,passwordProfile,pastProjects,postalCode,preferredDataLocation,preferredLanguage,preferredName,provisionedPlans,proxyAddresses,refreshTokensValidFromDateTime,responsibilities,schools,securityIdentifier,showInAddressList,signInActivity,signInSessionsValidFromDateTime,skills,state,streetAddress,surname,usageLocation,userPrincipalName,userType" Major caveat - some fields require other permissions like User-LifeCycleInfo.Read.All which would require each user to have redundant permissions just to call this many fields.
When you do not specify {
"@microsoft.graph.tips": "This request only returns a subset of the resource's properties. Your app will need to use $select to return non-default properties. To find out what other properties are available for this resource see https://learn.microsoft.com/graph/api/resources/user"
} |
I'd like to get to a solution where we don't have to have the new This would require verification:
Finally, what I meant by "Is the set of user attributes fixed at microsoft?" is this: is it possible to configure additional attributes queryable via |
I can push a commit with a query for all fields available under User.Read permission only. As for the fields being fixed, then yes it is fixed for what I found. The set of fields from that docs page is fixed and I have not found any way to extend or otherwise customize it. For error handling, |
Sounds perfect! Does this also solve the problem you initially encoutered? |
Yep! That's still many more identity fields than with standard traits alone, and like I said with Keto I can change someone's permissions by simply editing their role/department in Azure itself, no need for me to care about building UI and server to toggle people's roles. |
Nice. Please add an explanatory comment and a link to https://learn.microsoft.com/en-us/previous-versions/azure/ad/graph/api/entity-and-complex-type-reference#user-entity when you get around to updating the PR. Grazie! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! You'll have to rebase your changes please.
I think I may have messed this PR with rebasing |
0ba8560
to
b605170
Compare
Added comment and a link to MS documentation. Added cast checking to user["id"].(string)
874d9c5
to
182d730
Compare
Finally got around to tidying up the mess I made while rebasing. Hope it is ready to merge now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This reverts commit 4a7bcc9. Co-authored-by: Arne Luenser <[email protected]>
The change allows to pull more data from Graph API if using Microsoft OIDC. Currently it is only using ID field from the response, and this behaviour is not changed when
graph_select
field is empty (in fact, the response from Graph is reduced to ID only). By introducinggraph_select
the Microsoft Provider will request given fields, by appending $select parameter to the request.Claims.ID
will be populated as usual, but the entire response will be put intoClaims.RawClaims
. The list of available properties can be found here.Related issue(s)
Checklist
introduces a new feature.
contributing code guidelines.
vulnerability. If this pull request addresses a security vulnerability, I
confirm that I got the approval (please contact
[email protected]) from the maintainers to push
the changes.
works.
Further Comments
Little background on this pull request - I am implementing an internal system in my company and opted for Kratos to take care of sessions and all. I found it a little limiting to use standard fields available under
/userinfo
endpoint and saw that Graph API could be the solution to my problem. By giving it a little more flexibility, I can pull additional data, i.e.department
field so X department's managers cannot access Y departments's files, at the same time limiting user management to Azure only.I could not set my dev environment properly, so I skipped writing the proper tests; similarly I do not want to touch docs before hearing the feedback from the maintainers. It is a rather small improvement as it is also my first real code contribution to open-source, so I would greatly appreciate any help and comments on it! Thanks!