doc/user/group/saml_sso/group_sync.md
{{< details >}}
{{< /details >}}
{{< history >}}
{{< /history >}}
Use SAML group sync to assign users with specific roles to existing GitLab groups, based on the users' group assignment in the SAML identity provider (IdP). With SAML group sync you can create a many-to-many mapping between SAML IdP groups and GitLab groups.
For example, if the user @amelia is assigned to the security group in the SAML IdP,
you can use SAML group sync to assign @amelia to the security-gitlab group with Maintainer role,
and to the vulnerability group with Reporter role.
SAML group sync does not create groups. You have to first create a group, then create the mapping.
On GitLab.com, SAML group sync is configured by default. On GitLab Self-Managed, you must configure it manually.
Group sync determines the role and membership type of a user in the mapped group.
{{< details >}}
{{< /details >}}
When a user signs in, GitLab:
The group link mapping in GitLab is not tied to a specific IdP so you must configure all SAML IdPs to contain group attributes in the SAML response. This means that GitLab is able to match groups in the SAML response, regardless of the IdP that was used to sign in.
As an example, you have 2 IdPs: SAML1 and SAML2.
In GitLab, on a specific group, you have configured two group links:
gtlb-owner => Owner role.gtlb-dev => Developer role.In SAML1, the user is a member of gtlb-owner but not gtlb-dev.
In SAML2, the user is a member of gtlb-dev but not gtlb-owner.
When a user signs in to a group with SAML1, the SAML response shows that the user is a member of gtlb-owner, so GitLab sets the user's role in that group to be Owner.
The user then signs out and signs back in to the group with SAML2. The SAML response shows that the user is a member of gtlb-dev, so GitLab sets the user's role in that group to be Developer.
Now let's change the previous example so that the user is not a member of either gtlb-owner or gtlb-dev in SAML2.
SAML1, the user is given the Owner role in that group.SAML2, the user is removed from the group because they are not a member of either configured group link.If a user is a member of multiple SAML groups that map to the same GitLab group, the user is assigned the highest role from any of those SAML groups.
For example, if a user has the Guest role in a group and the Maintainer role in another group, they are assigned the Maintainer role.
If a user's role in a SAML group is higher than their role in one of its subgroups, their membership in the mapped GitLab group is different based on their assigned role in the mapped group.
If through group sync the user was assigned:
After a group sync, users who are not members of a mapped SAML group are removed from the group. On GitLab.com, users in the top-level group are assigned the default membership role instead of being removed.
For example, in the following diagram:
%%{init: { "fontFamily": "GitLab Sans" }}%%
graph TB
accTitle: Automatic member removal
accDescr: How group membership of users is determined before sign in if group sync is set up.
subgraph SAML users
SAMLUserA[Sidney Jones]
SAMLUserB[Zhang Wei]
SAMLUserC[Alex Garcia]
SAMLUserD[Charlie Smith]
end
subgraph SAML groups
SAMLGroupA["Group A"] --> SAMLGroupB["Group B"]
SAMLGroupA --> SAMLGroupC["Group C"]
SAMLGroupA --> SAMLGroupD["Group D"]
end
SAMLGroupB --> |Member|SAMLUserA
SAMLGroupB --> |Member|SAMLUserB
SAMLGroupC --> |Member|SAMLUserA
SAMLGroupC --> |Member|SAMLUserB
SAMLGroupD --> |Member|SAMLUserD
SAMLGroupD --> |Member|SAMLUserC
%%{init: { "fontFamily": "GitLab Sans" }}%%
graph TB
accTitle: Automatic member removal
accDescr: User membership for Sidney when she has not signed into group C, and group B has not configured group links.
subgraph GitLab users
GitLabUserA[Sidney Jones]
GitLabUserB[Zhang Wei]
GitLabUserC[Alex Garcia]
GitLabUserD[Charlie Smith]
end
subgraph GitLab groups
GitLabGroupA["Group A
(SAML configured)"] --> GitLabGroupB["Group B
(SAML Group Link not configured)"]
GitLabGroupA --> GitLabGroupC["Group C
(SAML Group Link configured)"]
GitLabGroupA --> GitLabGroupD["Group D
(SAML Group Link configured)"]
end
GitLabGroupB --> |Member|GitLabUserA
GitLabGroupC --> |Member|GitLabUserB
GitLabGroupC --> |Member|GitLabUserC
GitLabGroupD --> |Member|GitLabUserC
GitLabGroupD --> |Member|GitLabUserD
%%{init: { "fontFamily": "GitLab Sans" }}%%
graph TB
accTitle: Automatic member removal
accDescr: How membership of Alex Garcia works once she has signed into a group that has group links enabled.
subgraph GitLab users
GitLabUserA[Sidney Jones]
GitLabUserB[Zhang Wei]
GitLabUserC[Alex Garcia]
GitLabUserD[Charlie Smith]
end
subgraph GitLab groups after Alex Garcia signs in
GitLabGroupA[Group A]
GitLabGroupA["Group A
(SAML configured)"] --> GitLabGroupB["Group B
(SAML Group Link not configured)"]
GitLabGroupA --> GitLabGroupC["Group C
(SAML Group Link configured)"]
GitLabGroupA --> GitLabGroupD["Group D
(SAML Group Link configured)"]
end
GitLabGroupB --> |Member|GitLabUserA
GitLabGroupC --> |Member|GitLabUserB
GitLabGroupD --> |Member|GitLabUserC
GitLabGroupD --> |Member|GitLabUserD
Adding or changing a group sync configuration may remove users from the mapped GitLab group,
if the group names don't match the listed groups in the SAML response.
To avoid users being removed, before configuring group sync, ensure either:
groups attribute and the AttributeValue value matches the SAML Group Name in GitLab.If you use SAML Group Sync and have multiple GitLab nodes, for example in a distributed or highly available architecture, you must include the SAML configuration block on all Sidekiq nodes in addition to Rails application nodes.
{{< tabs >}}
{{< tab title="GitLab.com" >}}
To configure SAML Group Sync:
Groups or groups.{{< /tab >}}
{{< tab title="GitLab Self-Managed" >}}
To configure SAML Group Sync:
Configure the SAML OmniAuth Provider.
Ensure your SAML identity provider sends an attribute statement with the same name as the value of the groups_attribute setting. This attribute is case-sensitive. See the following provider configuration example in /etc/gitlab/gitlab.rb for reference:
gitlab_rails['omniauth_providers'] = [
{
name: "saml",
label: "Provider name", # optional label for login button, defaults to "Saml",
groups_attribute: 'Groups',
args: {
assertion_consumer_service_url: "https://gitlab.example.com/users/auth/saml/callback",
idp_cert_fingerprint: "43:51:43:a1:b5:fc:8b:b7:0a:3a:a9:b1:0f:66:73:a8",
idp_sso_target_url: "https://login.example.com/idp",
issuer: "https://gitlab.example.com",
name_identifier_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
}
}
]
{{< /tab >}}
{{< /tabs >}}
The value for Groups or groups in the SAML response may be either the group name or an ID.
For example, Azure AD sends the Azure Group Object ID instead of the name. Use the ID value when configuring SAML Group Links.
<saml:AttributeStatement>
<saml:Attribute Name="Groups">
<saml:AttributeValue xsi:type="xs:string">Developers</saml:AttributeValue>
<saml:AttributeValue xsi:type="xs:string">Product Managers</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
Other attribute names such as http://schemas.microsoft.com/ws/2008/06/identity/claims/groups
are not accepted as a source of groups.
For more information on configuring the required group attribute name in the SAML identity provider's settings, see example configurations for Azure AD and Okta.
SAML Group Sync only manages a group if that group has one or more SAML group links.
Prerequisites:
When SAML is enabled, users with the Owner role see a new menu item in group Settings > SAML Group Links.
To link the SAML groups:
saml:AttributeValue. The value entered here must exactly match the value sent in the SAML response. For some IdPs, this may be a group ID or object ID (Azure AD) instead of a friendly group name.{{< details >}}
{{< /details >}}
{{< history >}}
saml_groups_duo_pro_add_on_assignment. Disabled by default.{{< /history >}}
Prerequisites:
SAML Group Sync can manage GitLab Duo seat assignment and removal based on IdP group membership. Seats are only assigned when there are seats remaining in the subscription.
{{< tabs >}}
{{< tab title="GitLab.com" >}}
To configure for GitLab.com:
The checkbox does not appear for groups without an active GitLab Duo add-on subscription.
{{< /tab >}}
{{< tab title="GitLab Self-Managed" >}}
To configure Self-Managed:
Configure the SAML OmniAuth Provider.
Ensure your configuration includes groups_attribute and duo_add_on_groups. Any users who are a member of one or more of the duo_add_on_groups will have a GitLab Duo seat assigned, if a seat is available. See the following provider configuration example in /etc/gitlab/gitlab.rb for reference:
gitlab_rails['omniauth_providers'] = [
{
name: "saml",
label: "Provider name",
groups_attribute: 'Groups',
duo_add_on_groups: ['Developers', 'Freelancers'],
args: {
assertion_consumer_service_url: "https://gitlab.example.com/users/auth/saml/callback",
idp_cert_fingerprint: "43:51:43:a1:b5:fc:8b:b7:0a:3a:a9:b1:0f:66:73:a8",
idp_sso_target_url: "https://login.example.com/idp",
issuer: "https://gitlab.example.com",
name_identifier_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
}
}
]
{{< /tab >}}
{{< /tabs >}}
{{< history >}}
{{< /history >}}
[!note] Microsoft has announced that Azure Active Directory (AD) is being renamed to Entra ID.
<i class="fa-youtube-play" aria-hidden="true"></i> For a demo of group sync using Microsoft Azure, see Demo: SAML Group Sync.
Azure AD sends up to 150 groups in the groups claim.
When using Azure AD with SAML Group Sync, if a user in your organization is a member of more than 150 groups,
Azure AD sends a groups claim attribute in the SAML response for group overages,
and the user may be automatically removed from groups.
To avoid this issue, you can use the Azure AD integration, which:
12345678-9abc-def0-1234-56789abcde)
when it processes Group Sync.Alternatively, you can change the group claims to use the Groups assigned to the application option.
As part of the integration, you must allow GitLab to communicate with the Microsoft Graph API.
<!-- vale gitlab_base.SentenceSpacing = NO -->To configure Azure AD:
<application_name>, then on the confirmation dialog select Yes. The Status column for both permissions should change to a green check with Granted for <application_name>.After you configure Azure AD, you must configure GitLab to communicate with Azure AD.
With this configuration, if a user signs in with SAML and Azure sends a group claim in the response,
GitLab initiates a Group Sync job to call the Microsoft Graph API and retrieve the user's group membership.
Then the GitLab group membership is updated according to SAML Group Links.
The following table lists the GitLab settings and the corresponding Azure AD fields for the configuration:
| GitLab setting | Azure field |
|---|---|
| Tenant ID | Directory (tenant) ID |
| Client ID | Application (client) ID |
| Client Secret | Value (on Certificates & secrets page) |
{{< tabs >}}
{{< tab title="GitLab.com" >}}
To configure Azure AD for a GitLab.com group:
{{< /tab >}}
{{< tab title="GitLab Self-Managed" >}}
Prerequisites:
To configure for GitLab Self-Managed:
{{< /tab >}}
{{< /tabs >}}
{{< details >}}
{{< /details >}}
{{< history >}}
{{< /history >}}
You can enforce a global lock on SAML group memberships. This lock limits who can invite new members to subgroups where membership is synchronized with SAML Group Links.
When global group memberships lock is enabled:
Prerequisites:
To lock memberships to SAML Group Links synchronization: