Debian Codegraph @

doc/sources/admin/applications/gitlab.rst

raw
1 Gitlab
2 ======
3
4 |image0|
5
6 Presentation
7 ------------
8
9 See `Gitlab <https://about.gitlab.com/>`__ page for product
10 presentation.
11
12 Gitlab allows one to use SAML to authenticate users, see `official
13 documentation <https://docs.gitlab.com/ee/integration/saml.html>`__
14
15 SAML
16 ----
17
18 For this example, we use these sample values:
19
20 - Gitlab URL : https://gitlab.example.com
21 - LL::NG portal URL : https://auth.example.com
22
23 Gitlab configuration
24 ~~~~~~~~~~~~~~~~~~~~
25
26 Find the gitlab.rb file and add these settings:
27
28 ::
29
30 vi /etc/gitlab/gitlab.rb
31
32 .. code-block:: ruby
33
34 gitlab_rails['omniauth_enabled'] = true
35 gitlab_rails['omniauth_allow_single_sign_on'] = ['saml']
36 gitlab_rails['omniauth_auto_link_saml_user'] = true
37 gitlab_rails['omniauth_block_auto_created_users'] = false
38
39 gitlab_rails['omniauth_providers'] = [
40 {
41 name: 'saml',
42 args: {
43 assertion_consumer_service_url: 'https://gitlab.example.com/users/auth/saml/callback',
44 idp_cert_fingerprint: '99:BE:7B:68:3F:XX:7D:EF:6B:C3:XX:C0:0E:XX:D4:EA:02:XX:83:2A',
45 idp_sso_target_url: 'https://auth.example.com/saml/singleSignOn',
46 issuer: 'https://gitlab.example.com',
47 name_identifier_format: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress'
48 },
49 label: 'Login with LL::NG' # optional label for SAML login button
50 }
51 ]
52
53
54 .. tip::
55
56 To get the fingerprint of IDP certificate, copy SAML
57 certificate from LL::NG configuration in a file and use openssl:
58
59 ::
60
61 openssl x509 -in CERT.pem -noout -fingerprint
62
63
64
65 You can force SAML by default with this option:
66
67 .. code-block:: ruby
68
69 gitlab_rails['omniauth_auto_sign_in_with_provider'] = 'saml'
70
71 In this case, users won't be able to log directly on gitlab. Set it once
72 you are sure the SAML configuration is valid.
73
74 To apply changes:
75
76 ::
77
78 gitlab-ctl reconfigure
79
80 LL::NG configuration
81 ~~~~~~~~~~~~~~~~~~~~
82
83 We suppose LL::NG is configured as SAML IDP, and that you converted the
84 public key into a certificate for SAML signature. You must enable the
85 option to send certificates in response. If you don't want to, you need
86 to copy the certificate value into Gitlab configuration, in \`idp_cert\`
87 parameter.
88
89 You can get Gitlab SAML metadata on
90 https://gitlab.example.com/users/auth/saml/metadata
91
92 Register them in LL::NG and send these SAML attributes:
93
94 - mail => email
95 - uid => uid
96 - cn => name
97
98
99 .. attention::
100
101 The value from LL::NG mail session attribute must be the
102 email of the user in Gitlab database, in order to associate
103 accounts.
104
105 Manage groups
106 ~~~~~~~~~~~~~
107
108 You can pass groups to Gitlab. For this, declare groups attribute in
109 gitlab.rb:
110
111 .. code-block:: ruby
112
113 ...
114 gitlab_rails['omniauth_providers'] = [
115 {
116 name: 'saml',
117 groups_attribute: 'groups',
118 ...
119
120 And in LL::NG, export the groups attribute:
121
122 - groups => groups
123
124 OpenID Connect
125 --------------
126
127 **Alternatively** to SAML, you can choose to configure Gitlab to use
128 OpenID Connect.
129
130 .. _gitlab-configuration-1:
131
132 Gitlab configuration
133 ~~~~~~~~~~~~~~~~~~~~
134
135 In ``/etc/gitlab/gitlab.rb``
136
137 .. code-block:: ruby
138
139 ...
140 gitlab_rails['omniauth_allow_single_sign_on'] = ['openid_connect']
141 gitlab_rails['omniauth_block_auto_created_users'] = false
142
143 gitlab_rails['omniauth_providers'] = [
144 { 'name' => 'openid_connect',
145 'label' => 'LemonLDAP::NG',
146 'args' => {
147 'name' => 'openid_connect',
148 'issuer' => 'https://auth.example.com',
149 'scope' => ['openid', 'profile', 'email'],
150 'response_type' => 'code',
151 'client_auth_method' => 'client_secret_post',
152 'discovery' => true,
153 'uid_field' => 'sub',
154 'client_options' => {
155 'redirect_uri' => 'http://gitlab.example.com/users/auth/openid_connect/callback',
156 'identifier' => 'LEMONLDAP_CLIENT_ID',
157 'secret' => 'LEMONLDAP_CLIENT_SECRET',
158 }
159 }
160 }
161 ];
162
163 ...
164
165 .. _llng-configuration-1:
166
167 LL::NG configuration
168 ~~~~~~~~~~~~~~~~~~~~
169
170 Add an OpenID Connect RP to LemonLDAP::NG
171
172 - Chose a client ID and a client secret, and write the same values in
173 the ``gitlab.rb`` file above
174 - You need to chose an asymetrical signature algorithm for the ID Token
175 (RS256 or above)
176 - You also need to set a key identifier on your LemonLDAP::NG server in
177 ``OpenID Connect service`` » ``Security`` » ``Signing key ID`` (use
178 something like ``default`` as the value).
179 - Make sure the attribute containing the user email in the
180 LemonLDAP::NG session is mapped to the ``email`` claim.
181
182
183 .. attention::
184
185 You need to set a key identifier, or you will get a
186 *JSON::JWK::Set::KidNotFound* error on Gitlab
187
188 .. |image0| image:: /applications/gitlab_logo.png
189 :class: align-center
190