Only admins of the G Suite domain have access to the Admin SDK. Therefore, only G Suite admins can configure Google OAuth for Rancher.
Within Rancher, only administrators or users with the Manage Authentication can configure authentication.
Prerequisites
- You must have a configured.
- G Suite requires a top private domain FQDN as an authorized domain. One way to get an FQDN is by creating an A-record in Route53 for your Rancher server. You do not need to update your Rancher Server URL setting with that record, because there could be clusters using that URL.
- You must have the Admin SDK API enabled for your G Suite domain. You can enable it using the steps on
After the Admin SDK API is enabled, your G Suite domain’s API screen should look like this:
Setting up G Suite for OAuth with Rancher
Before you can set up Google OAuth in Rancher, you need to log in to your G Suite account and do the following:
- Generate OAuth2 credentials for the Rancher server
- Register the service account key as an OAuth Client
- Click to go to credentials page of your Google domain.
- Select your project and click OAuth consent screen.
- Go to Scopes for Google APIs and make sure email, profile and openid are enabled.
Result: Rancher has been added as an authorized domain for the Admin SDK API.
- Go to the Google API console, select your project, and go to the credentials page.
- On the Create Credentials dropdown, select OAuth client ID.
- Click Web application.
- Provide a name.
- Fill out the Authorized JavaScript origins and Authorized redirect URIs. Note: The Rancher UI page for setting up Google OAuth (available from the Global view under Security > Authentication > Google) provides you the exact links to enter for this step.
- Under Authorized JavaScript origins, enter your Rancher server URL.
- Under Authorized redirect URIs, enter your Rancher server URL appended with the path . For example, if your URI is , you will enter .
- Click on Create.
- After the credential is created, you will see a screen with a list of your credentials. Choose the credential you just created, and in that row on rightmost side, click Download JSON. Save the file so that you can provide these credentials to Rancher.
Result: Your OAuth credentials have been successfully created.
Since Rancher provides group-based membership access, we require the users to be able to get their own groups, and look up other users and groups when needed.
As a workaround to get this capability, G Suite recommends creating a service account and delegating authority of your G Suite domain to that service account.
This section describes how to:
- Create a service account
- Create a key for the service account and download the credentials as JSON
- Click and select your project for which you generated OAuth credentials.
- Click on Create Service Account.
- Enter a name and click Create.
- Click on Create Key and select the JSON option. Download the JSON file and save it so that you can provide it as the service account credentials to Rancher.
Result: Your service account is created.
You will need to grant some permissions to the service account you created in the last step. Rancher requires you to grant only read-only permissions for users and groups.
Using the Unique ID of the service account key, register it as an Oauth Client using the following steps:
Go to the Manage OAuth Client Access page.
Add the Unique ID obtained in the previous step in the Client Name field.
In the One or More API Scopes field, add the following scopes:
Click Authorize.
Result: The service account is registered as an OAuth client in your G Suite account.
Configuring Google OAuth in Rancher
- Sign into Rancher using a local user assigned the administrator role. This user is also called the local principal.
- From the Global view, click Security > Authentication from the main menu.
- Click Google. The instructions in the UI cover the steps to set up authentication with Google OAuth.
- Admin Email: Provide the email of an administrator account from your GSuite setup. In order to perform user and group lookups, google apis require an administrator’s email in conjunction with the service account key.
- Domain: Provide the domain on which you have configured GSuite. Provide the exact domain and not any aliases.
- Nested Group Membership: Check this box to enable nested group memberships. Rancher admins can disable this at any time after configuring auth.
- Step One is about adding Rancher as an authorized domain, which we already covered in
- For Step Two, provide the OAuth credentials JSON that you downloaded after completing this section. You can upload the file or paste the contents into the OAuth Credentials field.
- For Step Three, provide the service account credentials JSON that downloaded at the end of The credentials will only work if you successfully registered the service account key as an OAuth client in your G Suite account.
- Click Save.