debian-mirror-gitlab/doc/user/group/saml_sso/scim_setup.md

306 lines
18 KiB
Markdown
Raw Normal View History

2019-09-04 21:01:54 +05:30
---
type: howto, reference
2020-06-23 00:09:42 +05:30
stage: Manage
group: Access
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2019-09-04 21:01:54 +05:30
---
2021-03-11 19:13:27 +05:30
# SCIM provisioning using SAML SSO for GitLab.com groups **(PREMIUM SAAS)**
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/9388) in GitLab 11.10.
2019-07-31 22:56:46 +05:30
2019-09-04 21:01:54 +05:30
System for Cross-domain Identity Management (SCIM), is an open standard that enables the
automation of user provisioning. When SCIM is provisioned for a GitLab group, membership of
that group is synchronized between GitLab and the identity provider.
2021-02-22 17:27:13 +05:30
The GitLab [SCIM API](../../../api/scim.md) implements part of [the RFC7644 protocol](https://tools.ietf.org/html/rfc7644).
2019-07-31 22:56:46 +05:30
2020-05-24 23:13:21 +05:30
## Features
2021-01-03 14:25:43 +05:30
The following actions are available:
2019-07-31 22:56:46 +05:30
2020-05-24 23:13:21 +05:30
- Create users
- Deactivate users
2019-07-31 22:56:46 +05:30
The following identity providers are supported:
- Azure
2020-05-24 23:13:21 +05:30
- Okta
2019-07-31 22:56:46 +05:30
## Requirements
2020-05-24 23:13:21 +05:30
- [Group Single Sign-On](index.md) must be configured.
2019-09-30 21:07:59 +05:30
2019-10-12 21:52:04 +05:30
## GitLab configuration
2019-07-31 22:56:46 +05:30
2020-05-24 23:13:21 +05:30
Once [Group Single Sign-On](index.md) has been configured, we can:
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
1. On the top bar, select **Menu > Groups** and find your group.
1. On the left sidebar, select **Settings > SAML SSO**.
1. Select **Generate a SCIM token**.
1. Save the token and URL for use in the next step.
2019-07-31 22:56:46 +05:30
2020-10-24 23:57:45 +05:30
![SCIM token configuration](img/scim_token_v13_3.png)
2019-07-31 22:56:46 +05:30
2019-10-12 21:52:04 +05:30
## Identity Provider configuration
2019-07-31 22:56:46 +05:30
2020-05-24 23:13:21 +05:30
- [Azure](#azure-configuration-steps)
- [Okta](#okta-configuration-steps)
### Azure configuration steps
2019-07-31 22:56:46 +05:30
2020-10-24 23:57:45 +05:30
The SAML application that was created during [Single sign-on](index.md) setup for [Azure](https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/view-applications-portal) now needs to be set up for SCIM.
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
1. Enable automatic provisioning and administrative credentials by following the
2021-04-29 21:17:54 +05:30
[Azure's SCIM setup documentation](https://docs.microsoft.com/en-us/azure/active-directory/app-provisioning/use-scim-to-provision-users-and-groups#provisioning-users-and-groups-to-applications-that-support-scim).
2019-10-12 21:52:04 +05:30
During this configuration, note the following:
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
- The `Tenant URL` and `secret token` are the items retrieved in the
2019-09-30 21:07:59 +05:30
[previous step](#gitlab-configuration).
2021-12-11 22:18:48 +05:30
- We recommend setting a notification email and selecting the **Send an email notification when a failure occurs** checkbox.
2021-11-11 11:23:49 +05:30
- For mappings, we only leave `Synchronize Azure Active Directory Users to AppName` enabled.
`Synchronize Azure Active Directory Groups to AppName` is usually disabled. However, this
does not mean Azure AD users cannot be provisioned in groups. Leaving it enabled does not break
the SCIM user provisioning, but causes errors in Azure AD that may be confusing and misleading.
2019-07-31 22:56:46 +05:30
2019-10-12 21:52:04 +05:30
You can then test the connection by clicking on **Test Connection**. If the connection is successful, be sure to save your configuration before moving on. See below for [troubleshooting](#troubleshooting).
2019-07-31 22:56:46 +05:30
2019-10-12 21:52:04 +05:30
#### Configure attribute mapping
2019-07-31 22:56:46 +05:30
2021-04-29 21:17:54 +05:30
Follow [Azure documentation to configure the attribute mapping](https://docs.microsoft.com/en-us/azure/active-directory/app-provisioning/customize-application-attributes).
2019-09-30 21:07:59 +05:30
2021-04-29 21:17:54 +05:30
The following table below provides an attribute mapping known to work with GitLab. If
your SAML configuration differs from [the recommended SAML settings](index.md#azure-setup-notes),
modify the corresponding `customappsso` settings accordingly. If a mapping is not listed in the
2021-11-11 11:23:49 +05:30
table, use the Azure defaults. For a list of required attributes, refer to the [SCIM API documentation](../../../api/scim.md).
2019-07-31 22:56:46 +05:30
2021-11-11 11:23:49 +05:30
| Azure Active Directory Attribute | `customappsso` Attribute | Matching precedence |
| -------------------------------- | ------------------------------ | ------------------- |
| `objectId` | `externalId` | 1 |
| `userPrincipalName` | `emails[type eq "work"].value` | |
| `mailNickname` | `userName` | |
2019-07-31 22:56:46 +05:30
2021-04-29 21:17:54 +05:30
For guidance, you can view [an example configuration in the troubleshooting reference](../../../administration/troubleshooting/group_saml_scim.md#azure-active-directory).
2019-10-12 21:52:04 +05:30
1. Below the mapping list click on **Show advanced options > Edit attribute list for AppName**.
2020-04-22 19:07:51 +05:30
1. Ensure the `id` is the primary and required field, and `externalId` is also required.
2019-07-31 22:56:46 +05:30
2021-02-22 17:27:13 +05:30
NOTE:
2019-09-30 21:07:59 +05:30
`username` should neither be primary nor required as we don't support
that field on GitLab SCIM yet.
2021-04-29 21:17:54 +05:30
1. Save all changes.
1. In the **Provisioning** step, set the `Provisioning Status` to `On`.
2019-07-31 22:56:46 +05:30
2021-02-22 17:27:13 +05:30
NOTE:
2019-09-30 21:07:59 +05:30
You can control what is actually synced by selecting the `Scope`. For example,
2021-01-03 14:25:43 +05:30
`Sync only assigned users and groups` only syncs the users assigned to
the application (`Users and groups`), otherwise, it syncs the whole Active Directory.
2019-07-31 22:56:46 +05:30
2021-01-03 14:25:43 +05:30
Once enabled, the synchronization details and any errors appears on the
2021-02-22 17:27:13 +05:30
bottom of the **Provisioning** screen, together with a link to the audit events.
2019-09-04 21:01:54 +05:30
2021-02-22 17:27:13 +05:30
WARNING:
2021-01-03 14:25:43 +05:30
Once synchronized, changing the field mapped to `id` and `externalId` may cause a number of errors. These include provisioning errors, duplicate users, and may prevent existing users from accessing the GitLab group.
2019-12-26 22:10:19 +05:30
2020-05-24 23:13:21 +05:30
### Okta configuration steps
2021-01-29 00:20:46 +05:30
Before you start this section, complete the [GitLab configuration](#gitlab-configuration) process.
Make sure that you've also set up a SAML application for [Okta](https://developer.okta.com/docs/guides/build-sso-integration/saml2/overview/),
as described in the [Okta setup notes](index.md#okta-setup-notes)
Make sure that the Okta setup matches our documentation exactly, especially the NameID
configuration. Otherwise, the Okta SCIM app may not work properly.
2020-05-24 23:13:21 +05:30
1. Sign in to Okta.
2021-12-11 22:18:48 +05:30
1. Ensure you are in the Admin section by selecting the **Admin** button located in the top right. The admin button is not visible from the admin page.
2020-05-24 23:13:21 +05:30
2021-02-22 17:27:13 +05:30
NOTE:
2021-12-11 22:18:48 +05:30
If you're using the Developer Console, select **Developer Console** in the top
bar and then select **Classic UI**. Otherwise, you may not see the buttons described in the following steps:
2020-05-24 23:13:21 +05:30
2021-12-11 22:18:48 +05:30
1. In the **Application** tab, select **Add Application**.
1. Search for **GitLab**, find and select on the 'GitLab' application.
1. On the GitLab application overview page, select **Add**.
2021-10-27 15:23:28 +05:30
1. Under **Application Visibility** select both checkboxes. Currently the GitLab application does not support SAML authentication so the icon should not be shown to users.
2021-12-11 22:18:48 +05:30
1. Select **Done** to finish adding the application.
1. In the **Provisioning** tab, select **Configure API integration**.
2020-05-24 23:13:21 +05:30
1. Select **Enable API integration**.
- For **Base URL** enter the URL obtained from the GitLab SCIM configuration page
- For **API Token** enter the SCIM token obtained from the GitLab SCIM configuration page
2021-12-11 22:18:48 +05:30
1. Select 'Test API Credentials' to verify configuration.
1. Select **Save** to apply the settings.
1. After saving the API integration details, new settings tabs appear on the left. Select **To App**.
1. Select **Edit**.
1. Select the **Enable** checkbox for both **Create Users** and **Deactivate Users**.
1. Select **Save**.
2021-06-08 01:23:25 +05:30
1. Assign users in the **Assignments** tab. Assigned users are created and
2020-05-24 23:13:21 +05:30
managed in your GitLab group.
#### Okta Known Issues
The Okta GitLab application currently only supports SCIM. Continue
using the separate Okta [SAML SSO](index.md) configuration along with the new SCIM
application described above.
2021-04-17 20:07:23 +05:30
### OneLogin
2021-12-11 22:18:48 +05:30
As the developers of this app, OneLogin provides a "GitLab (SaaS)" app in their catalog, which includes a SCIM integration.
Please reach out to OneLogin if you encounter issues.
2021-04-17 20:07:23 +05:30
2020-03-13 15:44:24 +05:30
## User access and linking setup
2021-04-29 21:17:54 +05:30
During the synchronization process, all of your users get GitLab accounts, welcoming them
to their respective groups, with an invitation email. When implementing SCIM provisioning,
you may want to warn your security-conscious employees about this email.
2020-11-24 15:15:51 +05:30
The following diagram is a general outline on what happens when you add users to your SCIM app:
```mermaid
graph TD
A[Add User to SCIM app] -->|IdP sends user info to GitLab| B(GitLab: Does the email exists?)
B -->|No| C[GitLab creates user with SCIM identity]
B -->|Yes| D[GitLab sends message back 'Email exists']
```
2021-11-11 11:23:49 +05:30
During provisioning:
- Both primary and secondary emails are considered when checking whether a GitLab user account exists.
- Duplicate usernames are also handled, by adding suffix `1` upon user creation. For example,
due to already existing `test_user` username, `test_user1` is used.
2020-11-24 15:15:51 +05:30
As long as [Group SAML](index.md) has been configured, existing GitLab.com users can link to their accounts in one of the following ways:
2020-03-13 15:44:24 +05:30
- By updating their *primary* email address in their GitLab.com user account to match their identity provider's user profile email address.
- By following these steps:
1. Sign in to GitLab.com if needed.
2021-12-11 22:18:48 +05:30
1. In the identity provider's dashboard select the GitLab app or visit the **GitLab single sign-on URL**.
1. Select the **Authorize**.
2020-03-13 15:44:24 +05:30
2020-11-24 15:15:51 +05:30
We recommend users do this prior to turning on sync, because while synchronization is active, there may be provisioning errors for existing users.
2020-03-13 15:44:24 +05:30
New users and existing users on subsequent visits can access the group through the identify provider's dashboard or by visiting links directly.
2021-09-04 01:27:46 +05:30
[In GitLab 14.0 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/325712), GitLab users created with a SCIM identity display with an **Enterprise** badge in the **Members** view.
![Enterprise badge for users created with a SCIM identity](img/member_enterprise_badge_v14_0.png)
2020-03-13 15:44:24 +05:30
For role information, please see the [Group SAML page](index.md#user-access-and-management)
### Blocking access
2021-11-11 11:23:49 +05:30
To rescind access to the top-level group, all sub-groups, and projects, remove or deactivate the user
on the identity provider. SCIM providers generally update GitLab with the changes on demand, which
is minutes at most. The user's membership is revoked and they immediately lose access.
2020-11-24 15:15:51 +05:30
2021-02-22 17:27:13 +05:30
NOTE:
2021-11-11 11:23:49 +05:30
Deprovisioning does not delete the GitLab user account.
2020-11-24 15:15:51 +05:30
```mermaid
graph TD
A[Remove User from SCIM app] -->|IdP sends request to GitLab| B(GitLab: Is the user part of the group?)
B -->|No| C[Nothing to do]
B -->|Yes| D[GitLab removes user from GitLab group]
```
2020-03-13 15:44:24 +05:30
2019-10-12 21:52:04 +05:30
## Troubleshooting
2020-01-01 13:55:28 +05:30
This section contains possible solutions for problems you might encounter.
2020-11-24 15:15:51 +05:30
### How come I can't add a user after I removed them?
As outlined in the [Blocking access section](#blocking-access), when you remove a user, they are removed from the group. However, their account is not deleted.
When the user is added back to the SCIM app, GitLab cannot create a new user because the user already exists.
Solution: Have a user sign in directly to GitLab, then [manually link](#user-access-and-linking-setup) their account.
2021-01-29 00:20:46 +05:30
### How do I diagnose why a user is unable to sign in
2020-03-13 15:44:24 +05:30
2020-10-24 23:57:45 +05:30
Ensure that the user has been added to the SCIM app.
If you receive "User is not linked to a SAML account", then most likely the user already exists in GitLab. Have the user follow the [User access and linking setup](#user-access-and-linking-setup) instructions.
2021-06-08 01:23:25 +05:30
The **Identity** (`extern_uid`) value stored by GitLab is updated by SCIM whenever `id` or `externalId` changes. Users cannot sign in unless the GitLab Identity (`extern_uid`) value matches the `NameId` sent by SAML.
2020-03-13 15:44:24 +05:30
This value is also used by SCIM to match users on the `id`, and is updated by SCIM whenever the `id` or `externalId` values change.
2021-01-29 00:20:46 +05:30
It is important that this SCIM `id` and SCIM `externalId` are configured to the same value as the SAML `NameId`. SAML responses can be traced using [debugging tools](index.md#saml-debugging-tools), and any errors can be checked against our [SAML troubleshooting docs](index.md#troubleshooting).
2020-03-13 15:44:24 +05:30
2021-01-29 00:20:46 +05:30
### How do I verify user's SAML NameId matches the SCIM externalId
2020-03-13 15:44:24 +05:30
Group owners can see the list of users and the `externalId` stored for each user in the group SAML SSO Settings page.
2021-03-08 18:12:59 +05:30
A possible alternative is to use the [SCIM API](../../../api/scim.md#get-a-list-of-scim-provisioned-users) to manually retrieve the `externalId` we have stored for users, also called the `external_uid` or `NameId`.
2020-03-13 15:44:24 +05:30
2021-01-03 14:25:43 +05:30
To see how the `external_uid` compares to the value returned as the SAML NameId, you can have the user use a [SAML Tracer](index.md#saml-debugging-tools).
2020-03-13 15:44:24 +05:30
2021-01-29 00:20:46 +05:30
### Update or fix mismatched SCIM externalId and SAML NameId
2020-04-22 19:07:51 +05:30
Whether the value was changed or you need to map to a different field, ensure `id`, `externalId`, and `NameId` all map to the same field.
2020-03-13 15:44:24 +05:30
2021-02-22 17:27:13 +05:30
If the GitLab `externalId` doesn't match the SAML NameId, it needs to be updated in order for the user to sign in. Ideally your identity provider is configured to do such an update, but in some cases it may be unable to do so, such as when looking up a user fails due to an ID change.
2020-03-13 15:44:24 +05:30
2020-04-22 19:07:51 +05:30
Be cautious if you revise the fields used by your SCIM identity provider, typically `id` and `externalId`.
We use these IDs to look up users. If the identity provider does not know the current values for these fields,
that provider may create duplicate users.
2020-03-13 15:44:24 +05:30
2020-04-22 19:07:51 +05:30
If the `externalId` for a user is not correct, and also doesn't match the SAML NameID,
you can address the problem in the following ways:
2020-03-13 15:44:24 +05:30
2021-01-29 00:20:46 +05:30
- You can have users unlink and relink themselves, based on the ["SAML authentication failed: User has already been taken"](index.md#message-saml-authentication-failed-user-has-already-been-taken) section.
2020-04-22 19:07:51 +05:30
- You can unlink all users simultaneously, by removing all users from the SAML app while provisioning is turned on.
2021-03-08 18:12:59 +05:30
- It may be possible to use the [SCIM API](../../../api/scim.md#update-a-single-scim-provisioned-user) to manually correct the `externalId` stored for users to match the SAML `NameId`.
2021-06-08 01:23:25 +05:30
To look up a user, you need to know the desired value that matches the `NameId` as well as the current `externalId`.
2020-03-13 15:44:24 +05:30
2021-06-08 01:23:25 +05:30
It is important not to update these to incorrect values, since this causes users to be unable to sign in. It is also important not to assign a value to the wrong user, as this causes users to get signed into the wrong account.
2020-04-22 19:07:51 +05:30
2021-01-29 00:20:46 +05:30
### I need to change my SCIM app
2020-04-22 19:07:51 +05:30
2021-01-29 00:20:46 +05:30
Individual users can follow the instructions in the ["SAML authentication failed: User has already been taken"](index.md#i-need-to-change-my-saml-app) section.
2020-04-22 19:07:51 +05:30
2021-03-11 19:13:27 +05:30
Alternatively, users can be removed from the SCIM app which de-links all removed users. Sync can then be turned on for the new SCIM app to [link existing users](#user-access-and-linking-setup).
2021-01-29 00:20:46 +05:30
2021-02-22 17:27:13 +05:30
### The SCIM app is throwing `"User has already been taken","status":409` error message
Changing the SAML or SCIM configuration or provider can cause the following problems:
2021-11-11 11:23:49 +05:30
| Problem | Solution |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SAML and SCIM identity mismatch. | First [verify that the user's SAML NameId matches the SCIM externalId](#how-do-i-verify-users-saml-nameid-matches-the-scim-externalid) and then [update or fix the mismatched SCIM externalId and SAML NameId](#update-or-fix-mismatched-scim-externalid-and-saml-nameid). |
2021-03-08 18:12:59 +05:30
| SCIM identity mismatch between GitLab and the Identify Provider SCIM app. | You can confirm whether you're hitting the error because of your SCIM identity mismatch between your SCIM app and GitLab.com by using [SCIM API](../../../api/scim.md#update-a-single-scim-provisioned-user) which shows up in the `id` key and compares it with the user `externalId` in the SCIM app. You can use the same [SCIM API](../../../api/scim.md#update-a-single-scim-provisioned-user) to update the SCIM `id` for the user on GitLab.com. |
2021-02-22 17:27:13 +05:30
2021-01-29 00:20:46 +05:30
### Azure
#### How do I verify my SCIM configuration is correct?
Review the following:
- Ensure that the SCIM value for `id` matches the SAML value for `NameId`.
- Ensure that the SCIM value for `externalId` matches the SAML value for `NameId`.
Review the following SCIM parameters for sensible values:
- `userName`
- `displayName`
- `emails[type eq "work"].value`
#### Testing Azure connection: invalid credentials
When testing the connection, you may encounter an error: **You appear to have entered invalid credentials. Please confirm you are using the correct information for an administrative account**. If `Tenant URL` and `secret token` are correct, check whether your group path contains characters that may be considered invalid JSON primitives (such as `.`). Removing such characters from the group path typically resolves the error.
#### (Field) can't be blank sync error
2021-02-22 17:27:13 +05:30
When checking the Audit Events for the Provisioning, you can sometimes see the
2021-01-29 00:20:46 +05:30
error `Namespace can't be blank, Name can't be blank, and User can't be blank.`
This is likely caused because not all required fields (such as first name and last name) are present for all users being mapped.
As a workaround, try an alternate mapping:
1. Follow the Azure mapping instructions from above.
1. Delete the `name.formatted` target attribute entry.
1. Change the `displayName` source attribute to have `name.formatted` target attribute.