0.1.3 • Published 8 months ago

gitlab-google-scim v0.1.3

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

Gitlab to Google SCIM

Synchronizes your google users with gitlab users via SCIM. It supports mapping of different privileges for different groups & users.

Configuration

You need a few items of configuration. One side from Gitlab, and the other from Google Cloud to allow for API access to each. You will need the files produced by these steps for AWS Lambda deployment as well as locally running the sync tool. This how-to assumes you have Gitlab SSO configured and a Google SAML app to log in into Gitlab.

Google

First, you have to setup your API. In the project you want to use go to the Console and select API & Services > Enable APIs and Services. Search for Admin SDK and Enable the API.

You have to perform this tutorial to create a service account that you use to sync your users. Save the JSON file you create during the process. Please, keep this file safe, or store it in the AWS Secrets Manager.

In the domain-wide delegation for the Admin API, you have to specify the following scopes for the user.

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

Back in the Console go to the Dashboard for the API & Services and select "Enable API and Services". In the Search box type Admin and select the Admin SDK option. Click the Enable button.

You will have to specify the email address of an admin via the environment variable GOOGLE_ADMIN_EMAIL to assume this users role in the Directory.

Slack

To create a slack app and an incoming webhook, follow this page

Gitlab

You need two different credentials, a SCIM token and an API token with api access to the root group.

To get a SCIM token:

  • Open Gitlab, on the left sidebar, at the top, select Search GitLab () to find your group.
  • Select Settings > SAML SSO. Select Generate a SCIM token.
  • Save the Token from the Your SCIM token field. Please, keep this token safe, or store it in the AWS Secrets Manager.
  • The SCIM API endpoint URL field will be automatically calculated.

To get an API token, create a Group Access Token or a Personal Access Token.

Deployment configuration

NameRequiredDescription
GOOGLE_DOMAINyesgoogle domain that is allowed in gitlab
GOOGLE_ADMIN_EMAILyesemail of a google administrator that will be impersonated by the service account
GOOGLE_SA_KEY_SECRETnoAWS Secret name to retrieve the service account key from
GOOGLE_SA_KEY_FILEnoFilepath to retrieve the service account key from
GOOGLE_SA_KEYnoService account key
GITLAB_GROUPyesgitlab root group to sync users to
GITLAB_URLnogitlab instance base url, defaults to https://gitlab.com
GITLAB_SCIM_TOKEN_SECRETnoAWS Secret name to retrieve the SCIM token from
GITLAB_SCIM_TOKEN_FILEnoFilepath to retrieve the SCIM token from
GITLAB_SCIM_TOKENnoSCIM token
GITLAB_API_TOKEN_SECRETnoAWS Secret name to retrieve the API token from
GITLAB_API_TOKEN_FILEnoFilepath to retrieve the API token from
GITLAB_API_TOKENnoAPI token
DEFAULT_MEMBERSHIP_ROLEnoDefault gitlab role. Defaults to Minimal Access
ROLE_MAPPINGS_SECRETnoAWS Secret name to retrieve the gitlab role mappings from
ROLE_MAPPINGS_FILEnoFilepath to retrieve the gitlab role mappings from
ROLE_MAPPINGSnoRole mappings for gitlab
SLACK_WEBHOOK_URLnoSlack Webhook url to send notifications to
LOG_LEVELnoLevel of logs to print. Defaults to info
DRY_RUNnoWhether to only retrieve information, not create anything. Defaults to false

Development

To install dependencies:

bun install

To run:

bun run index.ts