'Set default group in Gitlab

We are running a self hosted instance of gitlab.

Is there a way to set the default group so that all new users are automatically assigned to this group upon account creation?



Solution 1:[1]

This feature is available when you integrate LDAP (or Active Directory) with GitLab.

LDAP group links

LDAP Group Links let you automatically add/remove users from groups based on their user attributes in LDAP. When users are created or sign in to GitLab, their GitLab group membership is synced against LDAP.

Without LDAP

If you do not use LDAP/AD, there might be two possible ways to work around this:

Use system hooks

You can use system hooks and capture user_create events in order to add newly created users to your group.

The disadvantage with this approach is that you'll have to setup a web application to receive these hooks and implement the appropriate logic.

Use automation scripts

Alternatively, you can write a script to automate this task periodically. The basic script would get a list of all GitLab users, then a list of all the group members. By comparing those lists, the script can add missing users to the group.

You could run this as a cron job on your GitLab host. Or you might even be able to use something like GitLab scheduled pipelines to run the script as a simple approach.

Your script might leverage the official API, or if you're running the script on the GitLab host itself, you can leverage the gitlab-rails console and script the steps in Ruby.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sytech