recampbell - in regards your pondering of Org Unit vs. Groups - my feeling is that mapping groups from GSuite to Jenkins makes the most sense.
Org Units are much more limiting since a user only exists in a single Org Unit (although OUs are hierarchical).
If you look at how GCP (Google Cloud) works, they let you assign groups directly into the permissions lists - so I can have engineering-team-X@example.com
as a group with permissions on a given project etc.
The Google API for managing / querying users as groups is solid and well-documented - happy to discuss when you're available - you know where I am!
orrc - in regards your question about the API - the API is a bit finicky to setup initially.
You have two options for calling the API
- a service account with appropriate scopes / permissions assigned
- a set of OAuth tokens for the "Jenkins" (or app), those token can then be used to issue an OAuth request (with required scopes) - which is basically a URL that a human will click on to generate a token. That token is then used by the Jenkins / app to issue directory HTTP requests.
The guidance from Google is that you can't use hard-coded tokens in OSS products (so Jenkins can't have a set burned in) - my gut feeling is that the most expedient way for Jenkins to work would be for end-users to create service accounts (this is not a GSuite user, but essentially a set of tokens) with the correct scopes. The service account credentials would then be entered into Jenkins as another pair of credential fields.
This guide is the one I used - https://developers.google.com/admin-sdk/directory/v1/quickstart/go (There are Java versions of the same thing if that's more your style). The example uses the "app" style token setup (rather than service account style setup)
Thinking about it more, its unclear to me if people would prefer to get the list of groups or organizational units.
I suppose that the groups are what are requested here. Perhaps populating the orgunit would be a separate feature request.
I notice that the G Suite API's also have notions of roles. I really have no clue what the use-cases and expectations are.
Just populating the groups as principles seems like it would address the crux of this request. Then you can go crazy with matrix-auth AFAICT.