Debian Codegraph @

doc/sources/admin/pgjsonsessionbackend.rst

raw
1 PgJSON session backend
2 ======================
3
4 This backend is the recommended one for production installations of LemonLDAP::NG.
5
6 Prerequisites
7 -------------
8
9 First, make sure you have installed the ``DBD::Pg`` perl module.
10
11 On Debian-based distributions ::
12
13 apt install libdbd-pg-perl libapache-session-browseable-perl
14
15 On Fedora-based distributions ::
16
17 yum install 'perl(DBD::Pg)' 'perl(Apache::Session::Browseable)'
18
19
20 The minimum required version of PostgreSQL is 9.3 with `support for JSON column types <https://www.postgresql.org/docs/9.3/functions-json.html>`__
21
22 Make sure you are using at least version 1.2.9 of ``Apache::Session::Browseable``, this might require installing it from Debian Backports or CPAN.
23
24 Create database schema
25 ----------------------
26
27 You can find the database schema in ``/usr/share/lemonldap-ng/ressources/sessions.pg.sql``.
28
29 LemonLDAP::NG configuration
30 ---------------------------
31
32 Go in the Manager and set the session module to ``Apache::Session::Browseable::PgJSON`` for each session type you intend to use:
33
34 * ``General parameters`` » ``Sessions`` » ``Session storage`` » ``Apache::Session module``
35 * ``General parameters`` » ``Sessions`` » ``Persistent sessions`` » ``Apache::Session module``
36 * ``CAS Service`` » ``CAS sessions module name``
37 * ``OpenID Connect Service`` » ``Sessions`` » ``Sessions module name``
38 * ``SAML2 Service`` » ``Advanced`` » ``SAML sessions module name``
39
40 Then, set the following module options:
41
42 =================== ================================================= =================================
43 Parameter name Comment Example
44 =================== ================================================= =================================
45 **DataSource** The `DBI <https://metacpan.org/pod/DBI>`__ string ``dbi:Pg:database=lemonldap-ng``
46 **UserName** The database username ``lemonldapng``
47 **Password** The database password ``mysuperpassword``
48 **TableName** Table name (optional) ``sessions``
49 **Commit** This setting is mandatory for PostgreSQL to work ``1``
50 =================== ================================================= =================================
51
52
53 .. tip::
54
55 Unlike other browseable modules, Pg::JSON does not require an ``Index`` parameter
56
57
58 .. tip::
59
60 We recommend adding the `tcp_user_timeout` and `keepalives_idle` options to the DBI string
61 Refer to `the full list of PostgreSQL connection options <https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS>`_
62
63 Patroni support
64 ~~~~~~~~~~~~~~~
65
66 Starting from version 1.3.17, `Apache::Session::Browseable <https://metacpan.org/pod/Apache::Session::Browseable>`_
67 provides a direct `Patroni PostgreSQL cluster <https://patroni.readthedocs.io/en/latest/>`_
68
69 This works like PgJSON but can take an additional parameter ``PatroniUrl``
70 which lists the Patroni servers available, then if there is a failure, the
71 driver will check for Patroni API to find the PostgreSQL leader and change
72 its ``DataSource`` to use it. To use it, set ``Apache::Session::Browseable::Patroni``
73 as **Sessions module** and set corresponding options. Example:
74
75 =================== ================================================================= =============================================================
76 Parameters Example Comment
77 =================== ================================================================= =============================================================
78 **DataSource** ``dbi:Pg:database=lemonldap-ng`` Unless an error occurs, the driver will use this data source
79 **UserName** ``lemonldapng``
80 **Password** ``mysuperpassword``
81 **TableName** ``sessions``
82 **Commit** ``1`` This setting is mandatory for PostgreSQL to work
83 **PatroniUrl** ``http://172.16.1.2:8008/cluster http://172.16.1.3:8008/cluster`` List here all ``*/cluster`` APIs
84 =================== ================================================================= =============================================================