You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-11Lines changed: 22 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# LDAP group sync script for Gitlab-CE
2
2
3
-
This nifty little PHP-CLI tool will synchronise user groups from an LDAP server to Gitlab community edition instance(s).
3
+
This nifty little PHP-CLI tool will synchronise users and user groups from an LDAP server to Gitlab community edition instance(s).
4
4
5
5
Though this functionality is available out of the box with Gitlab enterprise edition the pricing model is completely infeasible for teams of hobbyists working on non-revenue based projects but need to use a centralised authentication base.
6
6
7
-
This tool is not designed to sync the users themselves into Gitlab as Gitlab-CE can already authenticate fully against an LDAP instance. It is only designed to sync user group memberships, which is typically only available in Gitlab-EE.
7
+
As a bonus it can also do a light rake of LDAP users not currently in Gitlab, so those that haven't signed in for their first time can still have projects and permissions assigned to them. **This may make the tool unsuitable git Gitlab-EE as this would certainly impact its licensing fees!**
8
8
9
9
## Getting Started
10
10
@@ -18,7 +18,7 @@ Requirements for running this tool from a management station:
18
18
*[PHP](https://www.php.net) version 7.0 or later: Available to most Linux distributions via `apt-get` or `yum`. You don't need anything web related, but you will need the command line interface.
19
19
*[Composer](https://getcomposer.org/): Available to most Linux distributions via `apt-get` or `yum`, or manually download it as `composer.phar` alongside this tool.
20
20
* LDAP instance: Used for Gitlab's authentication. It can (likely) be Microsoft Active Directory, OpenLDAP, 389-DS (including FreeIPA), and likely any other LDAP system, though **most of my testing is using a 389-DS instance**.
21
-
*[Gitlab community edition](https://gitlab.com/gitlab-org/gitlab-ce/): This must be configured to authenticate against an LDAP instance.
21
+
*[Gitlab community edition](https://gitlab.com/gitlab-org/gitlab-ce/): This must be configured to authenticate against an LDAP instance already.
22
22
23
23
## Installing
24
24
@@ -67,7 +67,7 @@ Leaving this null will assume version 3.
67
67
68
68
The encryption protocol.
69
69
70
-
* "none" for unencrypted connections, usually port 389. (Generally only safe to use with "localhost".)
70
+
* "none" for unencrypted connections, usually port 389. (Generally only safe to use with "localhost" or a very tightly controlled link between this tool and the LDAP server.)
71
71
* "tls" for **explicit** SSL/TLS connections, usually on port 389. (Often called "STARTTLS".)
72
72
* "ssl" for **implicit** SSL/TLS connections, usually on port 636. (Often called "LDAPS".)
73
73
@@ -176,6 +176,16 @@ This section configures how to communicate with your Gitlab-CE instance.
176
176
177
177
#### options
178
178
179
+
##### userRake *(bool|null)*
180
+
181
+
Specify whether LDAP users should be raked into Gitlab. This means that LDAP users of which have not signed in for the first time will now have a minimal user record created for them on Gitlab in advance, which allows you to assign them projects and permissions, and of course put them into their respective groups in advance.
182
+
183
+
This could result in a large number of user records being created on Gitlab of which may never sign in.
184
+
185
+
**Do not enable this option if you so happen to have the enterprise edition of Gitlab as it can impact the licensing fees you need to pay.**
186
+
187
+
Default: *true*
188
+
179
189
##### createEmptyGroups *(bool|null)*
180
190
181
191
Specify whether groups containing no LDAP users should still be created in Gitlab.
@@ -265,7 +275,7 @@ Make up an instance name. For example if you had multiple Gitlab installations o
265
275
266
276
###### url *(string)*
267
277
268
-
Specify the full HTTP/HTTPS URL to this Gitlab instance, e.g. "https://athena.gitlab.example.com". This is the same URL you use to really visit this Gitlab installation from your web browser.
278
+
Specify the full HTTP/HTTPS URL to this Gitlab instance, e.g. "https://athena.gitlab.example.com" or "https://demeter.gitlab.example.com". This is the same URL you use to really visit this Gitlab installation from your web browser.
269
279
270
280
###### token *(string)*
271
281
@@ -279,21 +289,22 @@ Specify the LDAP server name used by this Gitlab instance. You can find this in
279
289
280
290
Once you've configured this tool you can run it from a CLI using:
281
291
282
-
`php bin/console ldap:groups:sync -d`
292
+
`php bin/console ldap:sync -d`
283
293
284
294
Depending on your system's PHP installation you may need to use `php-cli` instead of `php`. (This typically only occurs on WHM/cPanel based servers configured to host PHP via the fast process manager, PHP-FPM.)
285
295
286
-
The `-d` option is important for your first run. This enables "dry run" mode, meaning no changes will be persisted to your Gitlab instances. After running this tool you should evaluate the changes that will be made based on the output, then run it again without the `-d` option to persist the changes.
296
+
**The `-d` option is important for your first run.** This enables "dry run" mode, meaning no changes will be persisted to your Gitlab instances. After running this tool you should evaluate the changes that will be made based on the output, then run it again without the `-d` option to persist the changes.
287
297
288
298
If you'd like to see more verbose output you can add up to 3 `-v` switches, for example:
289
299
290
-
`php bin/console ldap:groups:sync -v`
291
-
`php bin/console ldap:groups:sync -vv`
292
-
`php bin/console ldap:groups:sync -vvv`
300
+
`php bin/console ldap:sync -v`
301
+
`php bin/console ldap:sync -vv`
302
+
`php bin/console ldap:sync -vvv`
293
303
294
304
If you'd like to only sync with a single Gitlab instance you can specify the name of it as per your configuration as an argument, for example:
0 commit comments