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 Order deny,allow
378 Deny from all
379 </Location>
380
381 Allowing configuration reload
382 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383
384 In order to allow configuration reload from a different server (if your
385 manager is on a different server or if you are using load-balancing),
386 you need to edit the access rule in **handler-apache2.conf**
387
388 .. code-block:: apache
389
390 <Location /reload>
391 #CHANGE THIS######
392 Require ip 127 ::1
393 ###########^^^^^^^
394 SetHandler perl-script
395 PerlResponseHandler Lemonldap::NG::Handler::ApacheMP2->reload
396 </Location>
397
398 Handler
399 ~~~~~~~
400
401 In order to protect your application VHosts with the LemonLDAP::NG
402 handler, you need to add these directives:
403
404 - Load Handler in Apache memory:
405
406 (in a global configuration file)
407
408 .. code-block:: apache
409
410 PerlOptions +GlobalRequest
411 PerlModule Lemonldap::NG::Handler::ApacheMP2
412
413 - Catch error pages:
414
415 .. code-block:: apache
416
417 ErrorDocument 403 http://auth.example.com/lmerror/403
418 ErrorDocument 404 http://auth.example.com/lmerror/404
419 ErrorDocument 500 http://auth.example.com/lmerror/500
420 ErrorDocument 502 http://auth.example.com/lmerror/502
421 ErrorDocument 503 http://auth.example.com/lmerror/503
422
423 Then, to protect a standard virtual host, the only configuration line to
424 add is:
425
426 .. code-block:: apache
427
428 PerlHeaderParserHandler Lemonldap::NG::Handler::ApacheMP2
429
430 See **test-apache2.conf** for a complete example of a protected
431 application
432
433 Nginx
434 -----
435
436
437 .. attention::
438
439 LemonLDAP::NG does not manage Nginx configuration
440
441 LemonLDAP::NG ships 3 Nginx configuration files:
442
443 - **portal-nginx.conf**: Portal virtual host, with REST/SOAP end points
444 - **manager-nginx.conf**: Manager virtual host
445 - **handler-nginx.conf** : Handler reload virtual hosts
446 - **test-nginx.conf** : Example protected application
447
448 See :doc:`how to deploy them<confignginx>`.
449
450
451 .. danger::
452
453 \ :doc:`LL::NG FastCGI<fastcgiserver>` server must be
454 enabled and started separately.
455
456 .. _portal-1:
457
458 Portal
459 ~~~~~~
460
461 After enabling any REST/SOAP endpoints in the Manager, you also need to
462 configure some for of authentication on the corresponding URLs in the
463 **portal-nginx.conf** configuration file.
464
465 By default, access to those URLs is denied:
466
467 .. code-block:: nginx
468
469 location ~ ^/index.psgi/adminSessions {
470 fastcgi_pass llng_portal_upstream;
471 deny all;
472 }
473
474 .. _allowing-configuration-reload-1:
475
476 Allowing configuration reload
477 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
478
479 In order to allow configuration reload from a different server (if your
480 manager is on a different server or if you are using load-balancing),
481 you need to edit the access rule in **handler-nginx.conf**
482
483 .. code-block:: nginx
484
485 location = /reload {
486
487 ## CHANGE THIS #
488 allow 127.0.0.1;
489 ######^^^^^^^^^#
490
491 deny all;
492
493 # FastCGI configuration
494 include /etc/nginx/fastcgi_params;
495 fastcgi_pass unix:__FASTCGISOCKDIR__/llng-fastcgi.sock;
496 fastcgi_param LLTYPE reload;
497 }
498
499 .. _handler-1:
500
501 Handler
502 ~~~~~~~
503
504 Nginx handler is provided by the
505 :doc:`LemonLDAP::NG FastCGI server<fastcgiserver>`.
506
507 - Handle errors:
508
509 .. code-block:: nginx
510
511 error_page 403 http://auth.example.com/lmerror/403;
512 error_page 404 http://auth.example.com/lmerror/404;
513 error_page 500 http://auth.example.com/lmerror/500;
514 error_page 502 http://auth.example.com/lmerror/502;
515 error_page 503 http://auth.example.com/lmerror/503;
516
517 To protect a standard virtual host, you must insert this (or create an
518 included file):
519
520 .. code-block:: nginx
521
522 # Insert $_user in logs
523 include /etc/lemonldap-ng/nginx-lmlog.conf;
524 access_log /var/log/nginx/access.log lm_combined;
525
526 # Internal call to FastCGI server
527 location = /lmauth {
528 internal;
529 include /etc/nginx/fastcgi_params;
530 fastcgi_pass unix:/var/run/llng-fastcgi-server/llng-fastcgi.sock;
531 fastcgi_pass_request_body off;
532 fastcgi_param CONTENT_LENGTH "";
533 fastcgi_param HTTP_HOST $host;
534 fastcgi_param X_ORIGINAL_URI $original_uri;
535 }
536
537 # Client requests
538 location / {
539 auth_request /lmauth;
540 set $original_uri $uri$is_args$args;
541 auth_request_set $lmremote_user $upstream_http_lm_remote_user;
542 auth_request_set $lmlocation $upstream_http_location;
543 error_page 401 $lmlocation;
544 try_files $uri $uri/ =404;
545
546 # Set REMOTE_USER (for FastCGI apps only)
547 #fastcgi_param REMOTE_USER $lmremote_user
548
549 ##################################
550 # PASSING HEADERS TO APPLICATION #
551 ##################################
552
553 # IF LUA IS SUPPORTED
554 #include /path/to/nginx-lua-headers.conf
555
556 # ELSE
557 # Set manually your headers
558 #auth_request_set $authuser $upstream_http_auth_user;
559 #proxy_set_header Auth-User $authuser;
560 # OR
561 #fastcgi_param HTTP_AUTH_USER $authuser;
562
563 # Then (if LUA not supported), change cookie header to hide LLNG cookie
564 #auth_request_set $lmcookie $upstream_http_cookie;
565 #proxy_set_header Cookie: $lmcookie;
566 # OR
567 #fastcgi_param HTTP_COOKIE $lmcookie;
568
569 # Insert then your configuration (fastcgi_* or proxy_*)
570
571 Configuration reload
572 --------------------
573
574 This part of documentation moved to :doc:`Events management<eventsmanagement>`
575
576 .. _configlocation-local-file:
577
578 Local file
579 ----------
580
581 LemonLDAP::NG configuration can be managed in a local file with `INI
582 format <http://en.wikipedia.org/wiki/INI_file>`__. This file is called
583 ``lemonldap-ng.ini`` and has the following sections:
584
585 - **all**: parameters for all modules
586 - **configuration**: where configuration is stored
587 - **apply**: reload URL for distant Hanlders
588 - **portal**: parameters only for Portal
589 - **manager**: parameters only for Manager
590 - **handler**: parameters only for Handler
591
592 When you set a parameter in ``lemonldap-ng.ini``, it will override the
593 parameter from the global configuration.
594
595 For example, to override configured skin for portal:
596
597 .. code-block:: ini
598
599 [portal]
600 portalSkin = dark
601
602
603 .. tip::
604
605 You need to know the technical name of configuration parameter
606 to do this. You can refer to :doc:`parameter list<parameterlist>` to
607 find it.