| 1 |
Databases |
| 2 |
========= |
| 3 |
|
| 4 |
============== ===== ======== |
| 5 |
Authentication Users Password |
| 6 |
============== ===== ======== |
| 7 |
✔ ✔ ✔ |
| 8 |
============== ===== ======== |
| 9 |
|
| 10 |
Presentation |
| 11 |
------------ |
| 12 |
|
| 13 |
Drivers |
| 14 |
~~~~~~~ |
| 15 |
|
| 16 |
LL::NG can use a lot of databases as authentication, users and password |
| 17 |
backend: |
| 18 |
|
| 19 |
- MariaDB/MySQL |
| 20 |
- PostGreSQL |
| 21 |
- Oracle |
| 22 |
- ... |
| 23 |
|
| 24 |
Indeed, any `Perl DBD |
| 25 |
driver <http://search.cpan.org/search?query=DBD%3A%3A&mode=module>`__ |
| 26 |
can be used. |
| 27 |
|
| 28 |
Schema |
| 29 |
~~~~~~ |
| 30 |
|
| 31 |
LL::NG can use two tables: |
| 32 |
|
| 33 |
- Authentication table: where login and password are stored |
| 34 |
- User table: where user data are stored (mail, name, etc.) |
| 35 |
|
| 36 |
|
| 37 |
.. tip:: |
| 38 |
|
| 39 |
Authentication table and user table can be the same. |
| 40 |
|
| 41 |
The password can be in plain text, or encoded with a SQL method (for example |
| 42 |
``SHA``, ``SHA1``, ``MD5`` or any valid method on database side). |
| 43 |
|
| 44 |
Example 1: two tables |
| 45 |
^^^^^^^^^^^^^^^^^^^^^ |
| 46 |
|
| 47 |
Authentication table |
| 48 |
'''''''''''''''''''' |
| 49 |
|
| 50 |
== ========== ======================================== |
| 51 |
id login password |
| 52 |
== ========== ======================================== |
| 53 |
0 coudot 1f777a6581e478499f4284e54fe2d4a4e513dfff |
| 54 |
1 xguimard a15a18c8bb17e6f67886a9af1898c018b9f5a072 |
| 55 |
2 tchemineau 1f777a6581e478499f4284e54fe2d4a4e513dfff |
| 56 |
== ========== ======================================== |
| 57 |
|
| 58 |
User table |
| 59 |
'''''''''' |
| 60 |
|
| 61 |
== ========== ================ ====================== |
| 62 |
id user name mail |
| 63 |
== ========== ================ ====================== |
| 64 |
0 coudot Clément OUDOT [email protected] |
| 65 |
1 tchemineau Thomas CHEMINEAU [email protected] |
| 66 |
2 xguimard Xavier GUIMARD [email protected] |
| 67 |
== ========== ================ ====================== |
| 68 |
|
| 69 |
Example 2: single table |
| 70 |
^^^^^^^^^^^^^^^^^^^^^^^ |
| 71 |
|
| 72 |
== ========== ======================================== ================ ====================== |
| 73 |
id user password name mail |
| 74 |
== ========== ======================================== ================ ====================== |
| 75 |
0 coudot 1f777a6581e478499f4284e54fe2d4a4e513dfff Clément OUDOT [email protected] |
| 76 |
1 tchemineau 1f777a6581e478499f4284e54fe2d4a4e513dfff Thomas CHEMINEAU [email protected] |
| 77 |
2 xguimard a15a18c8bb17e6f67886a9af1898c018b9f5a072 Xavier GUIMARD [email protected] |
| 78 |
== ========== ======================================== ================ ====================== |
| 79 |
|
| 80 |
SQL |
| 81 |
~~~ |
| 82 |
|
| 83 |
LL::NG will operate some SQL queries: |
| 84 |
|
| 85 |
- Authentication: select row in authentication table matching user and |
| 86 |
password |
| 87 |
- Search user: select row in user table matching user |
| 88 |
- Change password: update password column in authentication table |
| 89 |
matching user |
| 90 |
|
| 91 |
Configuration |
| 92 |
------------- |
| 93 |
|
| 94 |
In Manager, go in ``General Parameters`` > ``Authentication modules`` |
| 95 |
and choose Database (DBI) for authentication, users and/or password |
| 96 |
modules. |
| 97 |
|
| 98 |
Authentication level |
| 99 |
~~~~~~~~~~~~~~~~~~~~ |
| 100 |
|
| 101 |
The authentication level given to users authenticated with this module. |
| 102 |
|
| 103 |
|
| 104 |
.. attention:: |
| 105 |
|
| 106 |
As DBI is a login/password based module, the |
| 107 |
authentication level can be: |
| 108 |
|
| 109 |
- increased (+1) if portal is protected by SSL (HTTPS) |
| 110 |
- decreased (-1) if the portal autocompletion is allowed (see |
| 111 |
:doc:`portal customization<portalcustom>`) |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
Exported variables |
| 116 |
~~~~~~~~~~~~~~~~~~ |
| 117 |
|
| 118 |
List of columns to query to fill user session. See also |
| 119 |
:doc:`exported variables configuration<exportedvars>`. |
| 120 |
|
| 121 |
Connection |
| 122 |
~~~~~~~~~~ |
| 123 |
|
| 124 |
|
| 125 |
.. tip:: |
| 126 |
|
| 127 |
Connection settings can be configured differently for |
| 128 |
authentication process and user process. This allows one to use |
| 129 |
different databases for these process. By default, if user process |
| 130 |
connection settings are empty, authentication process connection |
| 131 |
settings will be used. |
| 132 |
|
| 133 |
- **Chain**: DBI chain, including database driver name and database |
| 134 |
name (for example: dbi:mysql:database=lemonldapng;host=localhost). |
| 135 |
- **User**: Connection user |
| 136 |
- **Password**: Connection password |
| 137 |
|
| 138 |
.. _schema-1: |
| 139 |
|
| 140 |
Schema |
| 141 |
~~~~~~ |
| 142 |
|
| 143 |
- **Authentication table**: authentication table name |
| 144 |
- **User table**: user table name |
| 145 |
- **Login field name**: name of authentication table column hosting |
| 146 |
login |
| 147 |
- **Password field name**: name of authentication table column hosting |
| 148 |
password |
| 149 |
- **Mail field name**: name of authentication table column hosting mail |
| 150 |
(for password reset) |
| 151 |
- **Login field name in user table**: name of user table column hosting |
| 152 |
login |
| 153 |
|
| 154 |
Password |
| 155 |
~~~~~~~~ |
| 156 |
|
| 157 |
- **Hash scheme**: SQL method for hashing password. Can be left blank |
| 158 |
for plain text passwords. The method will be forced to uppercase in |
| 159 |
SQL statement. |
| 160 |
- **Dynamic hash activation**: Activate dynamic hashing. With dynamic |
| 161 |
hashing, the hash scheme is recovered from the user password in the |
| 162 |
database during authentication. |
| 163 |
- **Supported non-salted schemes**: List of whitespace separated hash |
| 164 |
schemes. Every hash scheme MUST match a non-salted hash function in |
| 165 |
the database. LemonLDAP::NG relies on this hashing function for |
| 166 |
computing user password hashes. These hashes MUST NOT be salted (no |
| 167 |
random data used in conjunction with the password). |
| 168 |
- **Supported salted schemes**: List of whitespace separated salted |
| 169 |
hash schemes, of the form "**s**\ scheme", where scheme can match a |
| 170 |
non-salted hash function in the database. LemonLDAP::NG relies on |
| 171 |
this hashing function for computing user password hashes. |
| 172 |
Additional schemes for unix passwords are unixcrypt1 (MD5), |
| 173 |
unixcrypt5 (SHA256), unixcrypt6 (SHA512). |
| 174 |
- **Dynamic hash scheme for new passwords**: LemonLDAP::NG is able to |
| 175 |
store new passwords in the database (while modifying or |
| 176 |
reinitializing the password). You can choose a salted or non salted |
| 177 |
dynamic hashed password. The value must be an element of "Supported |
| 178 |
non-salted schemes" or "Supported salted schemes". |
| 179 |
|
| 180 |
|
| 181 |
.. attention:: |
| 182 |
|
| 183 |
The SQL function MUST have hexadecimal values as input |
| 184 |
AND output |
| 185 |
|
| 186 |
|
| 187 |
.. tip:: |
| 188 |
|
| 189 |
Here is an example for creating a postgreSQL SHA256 function. |
| 190 |
1. Install postgresql-contrib. 2. Activate extension: |
| 191 |
``CREATE EXTENSION pgcrypto;`` 3. Create the hash function: |
| 192 |
|
| 193 |
:: |
| 194 |
|
| 195 |
CREATE OR REPLACE FUNCTION sha256(varchar) returns text AS $$ |
| 196 |
SELECT encode(digest(decode($1, 'hex'), 'sha256'), 'hex') |
| 197 |
$$ LANGUAGE SQL STRICT IMMUTABLE; |