-
Notifications
You must be signed in to change notification settings - Fork 1.9k
google: add support for groups access without service account #4138
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
base: master
Are you sure you want to change the base?
google: add support for groups access without service account #4138
Conversation
cardoe
left a comment
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.
While I don't have a Google identity setup, this does seem correct to me from the description and the docs. Code wise it seems correct as well and adds a test.
|
Hi @devodev - do you plan on having this merged still? |
|
@iuliancristea yes waiting for a review :) |
|
Indeed sorry was responding on my phone, will fix. |
Set the upstream context when making API call to the admin service. Signed-off-by: Alexandre Barone <abalexandrebarone@gmail.com>
The Google connector has support for retrieving groups the user email is a member of using the Admin SDK API. This API requires using an authenticated client sourced from a service account granted domain-wide delegation. This account would be highly-privileged and give access to all Workspace users, which is less than ideal. This change adds an alternative method to retrieve group membership using the Cloud Identity API. When using the SearchDirectGroups API endpoint, we can provide an access token that has been authorized with the appropriate Cloud Identity API scope and search for transitive membership. In contrast to the existing method where the user is expected to specify the "groups" scope, this one relies on ther user setting one of the required Cloud Identity scope explicitly: - https://www.googleapis.com/auth/cloud-platform - https://www.googleapis.com/auth/cloud-identity.groups - https://www.googleapis.com/auth/cloud-identity.groups.readonly Signed-off-by: Alexandre Barone <abalexandrebarone@gmail.com>
The google oauth2 package uses different heuristics to try and find credentials. To avoid detecting user credentials, we already cover comon locaction for unix-based systems such as HOME. On the other hand, on windows it is possible tok find existing credentials under $APPDATA, therefore to mitigate, set the env var to /tmp like we do for HOME. Signed-off-by: Alexandre Barone <abalexandrebarone@gmail.com>
83fc2d2 to
efcb0d1
Compare
@nabokihms or @sagikazarmark are the approvers. |
Overview
Add support for retrieving groups the user is a member of without needing to configure a Service Account with Domain-Wide Delegation.
The Google connector has support for retrieving groups the user is a member of using the Admin SDK API. This API requires using an authenticated client sourced from a service account granted domain-wide delegation. This account would be highly-privileged and give access to all Workspace users, which is less than ideal.
This change adds an alternative method to retrieve group membership using the Cloud Identity API. When using the
SearchDirectGroupsAPI endpoint, we can provide an access token that has been authorized with the appropriate Cloud Identity API scope and search for direct and transitive membership.In contrast to the existing method where the user is expected to specify the
groupsscope, this one relies on the user setting one of the required Cloud Identity scope explicitly:This is similar to how Grafana provides this feature. Alternatively, we could also decide to support this feature by providing an explicit way in the config to choose which method to use.
This PR supersedes: #1896 which is now 4+ years old.
NOTE: contrary to what was mentioned in the above PR, this feature does NOT require Google Workspace Enterprise Standard, Enterprise Plus, Enterprise for Education, and Cloud Identity Premium accounts.
TODO: update documentation (supersede: dexidp/website#74).
Fixes: #3517
Testing
I added a basic unit test that mirrors the coverage that the existing
TestGetGroupsprovide.Additionally, I tested the new changes with a free version of Google Workspace + Google Cloud
I configured ArgoCD with the following:
To validate transitive group membership, I created the following group hierarchy:
admins@devodev.cloudargocd-admins@devodev.cloudalex@devodev.cloudAnd after login, I see the following log (+ admin role assigned):
Special notes for your reviewer
Couple of changes on this PR that are not directly related to the new feature:
golang.org/x/expto get access to new functions (slices.ContainsFunc).