Skip to content

Manage Google Group memberships via API #228

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

Closed
cblecker opened this issue Apr 19, 2019 · 17 comments
Closed

Manage Google Group memberships via API #228

cblecker opened this issue Apr 19, 2019 · 17 comments
Assignees
Labels
area/access Define who has access to what via IAM bindings, role bindings, policy, etc.

Comments

@cblecker
Copy link
Member

If we use the kubernetes.io gsuite, we should be able to manage group creation and membership via an API.

We should be able to create a service account, and then delegate it the following scopes via domain-wide delegation:

With these, we should be able to script creation of groups, administer their settings, and modify membership of them. It appears that we should be able to do this just with Gsuite Basic, without adding on any extra options/services/cost.

It appears there are also SDK libraries to get started:
https://godoc.org/google.golang.org/api/admin/directory/v1
https://godoc.org/google.golang.org/api/groupssettings/v1

@spiffxp
Copy link
Member

spiffxp commented May 1, 2019

I know Christoph ended up starting a steering@ thread, my main question is what are next steps

@spiffxp
Copy link
Member

spiffxp commented May 1, 2019

/assign @cblecker

@spiffxp
Copy link
Member

spiffxp commented May 1, 2019

/assign @dims
investigate how to recreate all of the groups we want from command line

migrate over groups enumerated in #206

save gitops-model for later (similar to dns)

@spiffxp
Copy link
Member

spiffxp commented May 1, 2019

I have created a [email protected] account, assigned to a "Group Admin" role, and given credentials to @dims

The intent is for this to be temporary / exploratory to prove we can do what we want via API. We should follow up with a more constrained account that has exactly what we need.

/assign
@dims and @cblecker can tap me if more is needed

@dims
Copy link
Member

dims commented May 1, 2019

@cblecker in the API that creates new groups, there is no support for switching on Allow members outside your organization toggle that is available in the UI.
https://developers.google.com/admin-sdk/directory/v1/reference/groups/insert

@dims
Copy link
Member

dims commented May 1, 2019

So we will have to create the groups by hand (with that option on) and then script the add/delete of members.

@cblecker
Copy link
Member Author

cblecker commented May 1, 2019

@dims: that's because that setting is in the OTHER API I mentioned at the top: https://developers.google.com/admin-sdk/groups-settings/manage 🤦‍♂

I don't know WHY Google had to split it up into two different API schemes, but yeah.

@dims
Copy link
Member

dims commented May 1, 2019

ah! thanks @cblecker

@spiffxp
Copy link
Member

spiffxp commented May 2, 2019

@dims
Copy link
Member

dims commented May 2, 2019

WIP is here #248 it uses the service account @spiffxp minted. all the APIs i need (so far!) are working. will hammer out a yaml structure and turn the WIP into something we can use.

Anyone else wants to be able to run the commands, please send me your GPG key, i used git-crypt to encrypt the json for the service account (see the PR above), at the moment it's me and @cblecker who can decrypt the file.

@dims
Copy link
Member

dims commented May 2, 2019

The scoped needed so far for the service account are

https://www.googleapis.com/auth/admin.directory.user.readonly
https://www.googleapis.com/auth/admin.directory.group
https://www.googleapis.com/auth/admin.directory.group.member
https://www.googleapis.com/auth/apps.groups.settings

in english ..

Sign_in_-_Google_Accounts

@dims
Copy link
Member

dims commented May 3, 2019

  • add new group
  • delete old group
  • add folks to group
  • delete folks from group

all works!

@spiffxp
Copy link
Member

spiffxp commented May 9, 2019

wg-k8s-infra-api-test@ renamed to wg-k8s-infra-api@

Screen Shot 2019-05-09 at 1 31 14 PM
Screen Shot 2019-05-09 at 1 31 28 PM

@spiffxp
Copy link
Member

spiffxp commented May 10, 2019

I once again walked through https://developers.google.com/admin-sdk/directory/v1/guides/delegation#delegate_domain-wide_authority_to_your_service_account for a client_id @dims provided to me, granting the following scopes

https://www.googleapis.com/auth/admin.directory.user.readonly
https://www.googleapis.com/auth/admin.directory.group
https://www.googleapis.com/auth/admin.directory.group.member
https://www.googleapis.com/auth/apps.groups.settings

@spiffxp
Copy link
Member

spiffxp commented May 15, 2019

Script is now runnable, two of us can run it: @dims and @cblecker (list of people who have gpg keys in repo)

@spiffxp
Copy link
Member

spiffxp commented May 15, 2019

/close

@k8s-ci-robot
Copy link
Contributor

@spiffxp: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/access Define who has access to what via IAM bindings, role bindings, policy, etc.
Projects
None yet
Development

No branches or pull requests

4 participants