Debian Codegraph @

doc/sources/admin/configlocation.rst

raw
1 Configuration overview
2 ======================
3
4 LemonLDAP::NG reads configuration from two sources:
5
6 .. image:: config-overview.png
7
8 The :ref:`local configuration<configlocation-local-file>` is generally stored in a ``/etc/lemonldap-ng/lemonldap-ng.ini`` file.
9
10 Its main purpose is to tell LemonLDAP::NG where it can find the shared
11 configuration. But it also contains some important settings like the logging
12 verbosity level.
13
14 The *shared configuration* is where most of the configuration is stored:
15 authentication sources, applications, session backends, UI parameters, and so
16 on. It needs to be shared between various componentes (*Portal* and *Handler*)
17 and that's why it's generally stored in a shared database.
18
19
20 Backends
21 --------
22
23 LemonLDAP::NG shared configuration is stored in a backend that allows all
24 modules to access it.
25
26
27 .. attention::
28
29 Note that all LL::NG components must have access:
30
31 - to the configuration backend
32 - to the sessions storage backend
33
34 Detailed configuration backends documentation is available
35 :ref:`here<start-configuration-database>`.
36
37 By default, configuration is stored in :doc:`files<fileconfbackend>`, so
38 access through network is not possible. To allow this, use
39 :doc:`SOAP<soapconfbackend>` for configuration access, or use a network
40 service like :doc:`SQL database<sqlconfbackend>` or
41 :doc:`LDAP directory<ldapconfbackend>`.
42
43 Configuration backend can be set in the
44 :ref:`local configuration file<configlocation-local-file>`, in ``configuration``
45 section.
46
47 For example, to configure the ``File`` configuration backend:
48
49 .. code-block:: ini
50
51 [configuration]
52 type=File
53 dirName = /usr/local/lemonldap-ng/data/conf
54
55
56 .. tip::
57
58 See
59 :doc:`How to change configuration backend<changeconfbackend>` to known
60 how to change this.
61
62 Manager
63 -------
64
65 Most of configuration can be done through LemonLDAP::NG Manager (by
66 default http://manager.example.com).
67
68 By default, Manager is protected to allow only the demonstration user
69 "dwho".
70
71
72 .. attention::
73
74 This user will not be available anymore if you configure
75 a new authentication backend! Remember to change the access rule in
76 Manager virtual host to allow new administrators.
77
78 If you can not access the Manager anymore, you can unprotect it by
79 editing ``lemonldap-ng.ini`` and changing the ``protection`` parameter:
80
81 .. code-block:: ini
82
83 [manager]
84
85 # Manager protection: by default, the manager is protected by a demo account.
86 # You can protect it :
87 # * by Apache itself,
88 # * by the parameter 'protection' which can take one of the following
89 # values :
90 # * authenticate : all authenticated users can access
91 # * manager : manager is protected like other virtual hosts: you
92 # have to set rules in the corresponding virtual host
93 # * rule: <rule> : you can set here directly the rule to apply
94 # * none : no protection
95
96
97 .. tip::
98
99 See :doc:`Manager protection documentation<managerprotection>`
100 to know how to use Apache modules or LL::NG to manage access to
101 Manager.
102
103 The Manager displays main branches:
104
105 - **General Parameters**: Authentication modules, portal, etc.
106 - **Variables**: User information, macros and groups used to fill SSO
107 session
108 - **Virtual Hosts**: Access rules, headers, etc.
109 - **SAML 2 Service**: SAML metadata administration
110 - **SAML identity providers**: Registered IDP
111 - **SAML service providers**: Registered SP
112 - **OpenID Connect Service**: OpenID Connect service configuration
113 - **OpenID Connect Providers**: Registered OP
114 - **OpenID Connect Relying Parties**: Registered RP
115
116 LemonLDAP::NG configuration is mainly a key/value structure, so Manager
117 will present all keys into a structured tree. A click on a key will
118 display the associated value.
119
120 When all modifications are done, click on ``Save`` to store
121 configuration.
122
123
124 .. danger::
125
126 LemonLDAP::NG will do some checks on configuration and
127 display errors and warnings if any. Configuration **is not saved** if
128 errors occur.
129
130
131 .. tip::
132
133
134
135 - :doc:`Configuration viewer<viewer>` allow some users to edit WebSSO
136 configuration in Read Only mode.
137
138 - You can set and display instance name in Manager menu by editing
139 ``lemonldap-ng.ini`` in [manager] section:
140
141 .. code:: ini
142
143 [manager]
144 instanceName = LLNG_Demo
145
146
147 .. _configuration-placeholders:
148
149 Configuration placeholders
150 ~~~~~~~~~~~~~~~~~~~~~~~~~~
151
152 It is possible to use environment variable placeholders anywhere in
153 configuration. Those placeholders will be replaced by each LLNG component
154 using environment variables set locally.
155 The format is: ``%SERVERENV:VariableName%``.
156 To enable this feature, you must edit ``lemonldap-ng.ini`` to set
157 ``useServerEnv`` value in ``[configuration]`` section:
158
159 .. code:: ini
160
161 [configuration]
162 useServerEnv = 1
163
164
165 You can also create :doc:`your own placeholder <customconfigplaceholder>` to
166 fetch data from password vaults or other sources.
167
168
169 Manager API
170 -----------
171
172 Since 2.0.8, a Manager API is available for:
173
174 - Second factors management for users
175 - OpenID Connect RP management
176 - SAML SP management
177
178 See `Manager API
179 documentation <https://lemonldap-ng.org/manager-api/2.0/>`__.
180
181
182 .. attention::
183
184 To access Manager API, enable the ``manager-api``
185 virtual host and change the access rule. You can protect the API through
186 Basic authentication, IP white list or any other condition.
187
188 Configuration text editor
189 -------------------------
190
191 LemonLDAP::NG provide a script that allows one to edit configuration
192 without graphical interface, this script is called ``lmConfigEditor``
193 and is stored in the LemonLDAP::NG bin/ directory, for example
194 /usr/share/lemonldap-ng/bin:
195
196 - On Debian:
197
198 ::
199
200 /usr/share/lemonldap-ng/bin/lmConfigEditor
201
202 - On CentOS:
203
204 ::
205
206 /usr/libexec/lemonldap-ng/bin/lmConfigEditor
207
208
209 .. tip::
210
211 This script must be run as root, it will then use the Apache
212 user and group to access configuration.
213
214 .. tip::
215
216 You can change the user and group by setting ``--user`` and
217 ``--group`` options in the command line.
218
219 The script uses the ``editor`` system command, that links to your
220 favorite editor. To change it:
221
222 ::
223
224 update-alternatives --config editor
225
226 The configuration is displayed as a big Perl Hash, that you can edit:
227
228 .. code-block:: perl
229
230 $VAR1 = {
231 'ldapAuthnLevel' => '2',
232 'notificationWildcard' => 'allusers',
233 'loginHistoryEnabled' => '1',
234 'key' => 'q`e)kJE%<&wm>uaA',
235 'samlIDPSSODescriptorSingleSignOnServiceHTTPPost' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST;#PORTAL#/saml/singleSignOn;',
236 'portalSkin' => 'pastel',
237 'failedLoginNumber' => '5',
238 ...
239 };
240
241 If a modification is done, the configuration is saved with a new
242 configuration number. Else, current configuration is kept.
243
244 .. _configlocation-command-line-interface-cli:
245
246 Command Line Interface (CLI)
247 ----------------------------
248
249 LemonLDAP::NG provide a script that allows one to edit configuration
250 items in non interactive mode. This script is called
251 ``lemonldap-ng-cli`` and is stored in the LemonLDAP::NG bin/ directory,
252 for example /usr/share/lemonldap-ng/bin:
253
254 - On Debian:
255
256 ::
257
258 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli
259
260 - On CentOS:
261
262 ::
263
264 /usr/libexec/lemonldap-ng/bin/lemonldap-ng-cli
265
266
267 .. tip::
268
269 This script must be run as root, it will then use the Apache
270 user and group to access configuration.
271
272 To see available actions, do:
273
274 ::
275
276 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli help
277
278 You can force an update of configuration cache with:
279
280 ::
281
282 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli update-cache
283
284 To get information about current configuration:
285
286 ::
287
288 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli info
289
290 To view a configuration parameter, for example portal URL:
291
292 ::
293
294 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli get portal
295
296 To set a parameter, for example domain:
297
298 ::
299
300 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli set domain example.org
301
302 To delete a parameter, for example portalSkinBackground:
303
304 ::
305
306 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli del portalSkinBackground
307
308 .. tip::
309
310 Use addKey and delKey actions to manage values of hash configuration parameters
311
312 You can use accessors (options) to change the behavior:
313
314 - -sep: separator of hierarchical values (by default: /).
315 - -iniFile: the lemonldap-ng.ini file to use if not default value.
316 - -yes: do not prompt for confirmation before saving new configuration.
317 - -cfgNum: the configuration number. If not set, it will use the latest
318 configuration.
319 - -force: set it to 1 to save a configuration earlier than latest.
320
321 Additional options:
322
323 - --user=<user>: change user running the script
324 - --group=<group>: change group running the script
325
326 Some examples:
327
328 ::
329
330 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli -cfgNum 10 get exportedHeaders/test1.example.com
331 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli -yes 1 set notification 1
332 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli -sep ',' get macros,_whatToTrace
333 /usr/share/lemonldap-ng/bin/lemonldap-ng-cli get portal --user=nginx --group=nginx
334
335
336 .. tip::
337
338 See :doc:`other examples<cli_examples>`.
339
340
341 .. _configlocation-apache:
342
343 Apache
344 ------
345
346
347 .. attention::
348
349 LemonLDAP::NG does not manage Apache
350 configuration
351
352 LemonLDAP::NG ships 3 Apache configuration files:
353
354 - **portal-apache2.conf**: Portal virtual host, with SOAP/REST end
355 points
356 - **manager-apache2.conf**: Manager virtual host
357 - **handler-apache2.conf** : Handler declaration, reload virtual hosts
358 - **test-apache2.conf** : Example protected virtual hosts
359
360 See :doc:`how to deploy them<configapache>`.
361
362 .. _configlocation-portal:
363
364 Portal
365 ~~~~~~
366
367 After enabling any REST/SOAP endpoints in the Manager, you also need to
368 configure some for of authentication on the corresponding URLs in the
369 **portal-apache2.conf** configuration file.
370
371 By default, access to those URLs is denied:
372
373 .. code-block:: apache
374
375 # REST/SOAP functions for sessions management (disabled by default)
376 <Location /index.fcgi/adminSessions>
377 Require all denied
378 </Location>
379
380 Allowing configuration reload
381 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382
383 In order to allow configuration reload from a different server (if your
384 manager is on a different server or if you are using load-balancing),
385 you need to edit the access rule in **handler-apache2.conf**
386
387 .. code-block:: apache
388
389 <Location /reload>
390 #CHANGE THIS######
391 Require ip 127 ::1
392 ###########^^^^^^^
393 SetHandler perl-script
394 PerlResponseHandler Lemonldap::NG::Handler::ApacheMP2->reload
395 </Location>
396
397 Handler
398 ~~~~~~~
399
400 In order to protect your application VHosts with the LemonLDAP::NG
401 handler, you need to add these directives:
402
403 - Load Handler in Apache memory:
404
405 (in a global configuration file)
406
407 .. code-block:: apache
408
409 PerlOptions +GlobalRequest
410 PerlModule Lemonldap::NG::Handler::ApacheMP2
411
412 - Catch error pages:
413
414 .. code-block:: apache
415
416 ErrorDocument 403 http://auth.example.com/lmerror/403
417 ErrorDocument 404 http://auth.example.com/lmerror/404
418 ErrorDocument 500 http://auth.example.com/lmerror/500
419 ErrorDocument 502 http://auth.example.com/lmerror/502
420 ErrorDocument 503 http://auth.example.com/lmerror/503
421
422 Then, to protect a standard virtual host, the only configuration line to
423 add is:
424
425 .. code-block:: apache
426
427 PerlHeaderParserHandler Lemonldap::NG::Handler::ApacheMP2
428
429 See **test-apache2.conf** for a complete example of a protected
430 application
431
432 Nginx
433 -----
434
435
436 .. attention::
437
438 LemonLDAP::NG does not manage Nginx configuration
439
440 LemonLDAP::NG ships 3 Nginx configuration files:
441
442 - **portal-nginx.conf**: Portal virtual host, with REST/SOAP end points
443 - **manager-nginx.conf**: Manager virtual host
444 - **handler-nginx.conf** : Handler reload virtual hosts
445 - **test-nginx.conf** : Example protected application
446
447 See :doc:`how to deploy them<confignginx>`.
448
449
450 .. danger::
451
452 \ :doc:`LL::NG FastCGI<fastcgiserver>` server must be
453 enabled and started separately.
454
455 .. _portal-1:
456
457 Portal
458 ~~~~~~
459
460 After enabling any REST/SOAP endpoints in the Manager, you also need to
461 configure some for of authentication on the corresponding URLs in the
462 **portal-nginx.conf** configuration file.
463
464 By default, access to those URLs is denied:
465
466 .. code-block:: nginx
467
468 location ~ ^/index.psgi/adminSessions {
469 fastcgi_pass llng_portal_upstream;
470 deny all;
471 }
472
473 .. _allowing-configuration-reload-1:
474
475 Allowing configuration reload
476 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
477
478 In order to allow configuration reload from a different server (if your
479 manager is on a different server or if you are using load-balancing),
480 you need to edit the access rule in **handler-nginx.conf**
481
482 .. code-block:: nginx
483
484 location = /reload {
485
486 ## CHANGE THIS #
487 allow 127.0.0.1;
488 ######^^^^^^^^^#
489
490 deny all;
491
492 # FastCGI configuration
493 include /etc/nginx/fastcgi_params;
494 fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
495 fastcgi_param LLTYPE reload;
496 }
497
498 .. _handler-1:
499
500 Handler
501 ~~~~~~~
502
503 Nginx handler is provided by the
504 :doc:`LemonLDAP::NG FastCGI server<fastcgiserver>`.
505
506 - Handle errors:
507
508 .. code-block:: nginx
509
510 error_page 403 http://auth.example.com/lmerror/403;
511 error_page 404 http://auth.example.com/lmerror/404;
512 error_page 500 http://auth.example.com/lmerror/500;
513 error_page 502 http://auth.example.com/lmerror/502;
514 error_page 503 http://auth.example.com/lmerror/503;
515
516 To protect a standard virtual host, you must insert this (or create an
517 included file):
518
519 .. code-block:: nginx
520
521 # Insert $_user in logs
522 include /etc/lemonldap-ng/nginx-lmlog.conf;
523 access_log /var/log/nginx/access.log lm_combined;
524
525 # Internal call to FastCGI server
526 location = /lmauth {
527 internal;
528 include /etc/nginx/fastcgi_params;
529 fastcgi_pass unix:/var/run/llng-fastcgi-server/llng-fastcgi.sock;
530 fastcgi_pass_request_body off;
531 fastcgi_param CONTENT_LENGTH "";
532 fastcgi_param HTTP_HOST $host;
533 fastcgi_param X_ORIGINAL_URI $original_uri;
534 }
535
536 # Client requests
537 location / {
538 auth_request /lmauth;
539 set $original_uri $uri$is_args$args;
540 auth_request_set $lmremote_user $upstream_http_lm_remote_user;
541 auth_request_set $lmlocation $upstream_http_location;
542 error_page 401 $lmlocation;
543 try_files $uri $uri/ =404;
544
545 # Set REMOTE_USER (for FastCGI apps only)
546 #fastcgi_param REMOTE_USER $lmremote_user
547
548 ##################################
549 # PASSING HEADERS TO APPLICATION #
550 ##################################
551
552 # IF LUA IS SUPPORTED
553 #include /path/to/nginx-lua-headers.conf
554
555 # ELSE
556 # Set manually your headers
557 #auth_request_set $authuser $upstream_http_auth_user;
558 #proxy_set_header Auth-User $authuser;
559 # OR
560 #fastcgi_param HTTP_AUTH_USER $authuser;
561
562 # Then (if LUA not supported), change cookie header to hide LLNG cookie
563 #auth_request_set $lmcookie $upstream_http_cookie;
564 #proxy_set_header Cookie: $lmcookie;
565 # OR
566 #fastcgi_param HTTP_COOKIE $lmcookie;
567
568 # Insert then your configuration (fastcgi_* or proxy_*)
569
570 Configuration reload
571 --------------------
572
573 This part of documentation moved to :doc:`Events management<eventsmanagement>`
574
575 .. _configlocation-local-file:
576
577 Local file
578 ----------
579
580 LemonLDAP::NG configuration can be managed in a local file with `INI
581 format <http://en.wikipedia.org/wiki/INI_file>`__. This file is called
582 ``lemonldap-ng.ini`` and has the following sections:
583
584 - **all**: parameters for all modules
585 - **configuration**: where configuration is stored
586 - **apply**: reload URL for distant Hanlders
587 - **portal**: parameters only for Portal
588 - **manager**: parameters only for Manager
589 - **handler**: parameters only for Handler
590
591 When you set a parameter in ``lemonldap-ng.ini``, it will override the
592 parameter from the global configuration.
593
594 For example, to override configured skin for portal:
595
596 .. code-block:: ini
597
598 [portal]
599 portalSkin = dark
600
601
602 .. tip::
603
604 You need to know the technical name of configuration parameter
605 to do this. You can refer to :doc:`parameter list<parameterlist>` to
606 find it.