LDAP認証

LDAPを使用する利点は、すべてのユーザーとグループの情報を、集中管理された1つのサーバーに置くことができることです。

まず最初にすることは、Linuxシステムにphp ldap extensionをインストールすることです。

apt install php8.4-ldap

Then, in order to enable the LDAP support Lizmap, you have to install a module that allows to authenticate with Ldap.

Note: in previous version (Lizmap 3.9 and lower), there was an embedded module named ldapdao. Since Lizmap 3.10, it does not exists anymore, and is replaced by a new module, multiauth, you have to install.

Be sure PHP is installed, as weel as Composer (apt install composer in Debian, or install by hand from https://getcomposer.org ).

Installing the module

In lizmap/my-packages, create the composer.json file if it does not exist yet (by copying composer.json.dist).

Add the PHP package jelix/multiauth-module:

composer require jelix/multiauth-module

If you want an interface to setup the ldap configuration (recommended), add the package jelix/ldapadmin-module:

composer require jelix/ldapadmin-module

Then go into the lizmap/install directory, and enable the modules into Lizmap:

cd ../install/
php configurator.php multiauth
# and if you installed ldapadmin:
php configurator.php ldapadmin

Finish the installation with:

php installer.php

Configuring LDAP

There is already a configuration set into lizmap. See the [ldap:lizmapldap] section into your profiles.ini.php, with some settings that allow to connect to your ldap server, and to search users into the ldap. The default parameters are typical parameters to connect and search to an OpenLdap server. Of course, they are just an example, and you have to modify them, according your Ldap structure.

[ldap:lizmapldap]
hostname=localhost
port=389
adminUserDn="cn=admin,ou=lizmap,dc=com"
adminPassword=""
searchUserBaseDN="dc=XY,dc=fr"
searchUserFilter="(&(objectClass=posixAccount)(uid=%%LOGIN%%))"
searchAttributes="uid:login,givenName:firstname,sn:lastname,mail:email,organization:organization,street:street,postcode:postcode,city:city"
searchGroupFilter=
searchGroupProperty="cn"
searchGroupBaseDN=""

If you install ldapadmin, you have a new menu entry in the administration page of Lizmap : "Ldap configuration". It allows to edit and tests all of these parameters.

これらのパラメータの設定方法については、以下のセクションで詳しく説明しています。

ユーザーデータの設定プロパティ

パスワードを確認したり、ユーザーが初めて認証したときにLizmapに登録するために、プラグインはユーザーに関するいくつかのデータを必要とします。

どのldap属性を取得できるのか、どのデータベースフィールドがldap属性の値を受け取るのかを指示する必要があります。

このような情報は、 searchAttributes プロパティに記述します。 <ldap attribute>:<table field> は間まで区切られた名前のペアです。

例えば searchAttributes="uid:login,firstname,sn:lastname,mail:email,dn:" ような設定の場合

  • uid というLDAP 属性の値が login フィールドに格納されます。

  • sn というLDAP 属性の値が lastname フィールドに格納されます。

  • firstname というldap属性の値は、フィールド名や : がないため、同じ名前のフィールドに格納されます。

  • dn プロパティのマッピングはありません。フィールド名のない : があります。これはldapから読み込まれ、bindUserDN のDNテンプレートに使用することができます。(下記参照).

Lizmapで使用可能なフィールドのリストは以下の通りです。login, email, firstname, lastname, organization, phonenumber, street, postcode, city, country。login と email のみ必須です。その他はオプションです。

認証のための設定プロパティ

このプラグインはユーザをldapで認証する前に,ユーザのプロパティを取得します.このプラグインは,searchUserFilter と searchAttributes という2つの設定パラメータを利用します.

searchUserFilter には,ldap クエリと,ユーザが指定したログイン名で置き換えられる %%LOGIN%% プレースホルダを指定します.

例えば、 searchUserFilter="(&(objectClass=posixAccount)(uid=%%LOGIN%%))"

また、searchUserBaseDN には、検索のベースとなるDNを指定することもできます。例えば、 searchUserBaseDN="ou=ADAM users,o=Microsoft,c=US" 。

複雑なLDAPの構造を持っている場合には、複数の検索フィルターを指定することができることに注意してください。アイテムリストを示すには [] を使います.

searchUserFilter[]="(&(objectClass=posixAccount)(uid=%%LOGIN%%))"
searchUserFilter[]="(&(objectClass=posixAccount)(cn=%%LOGIN%%))"

To verify the password, the plugin needs the DN (Distinguished Name) corresponding to the user. The ldap property containing the DN should be indicated into the bindAttribute. Its default value is dn.

ユーザー権限の設定プロパティ

Lizmapにグループ権限を設定しており、これらのグループがldapグループと一致する場合、ユーザーのldapグループに応じて、ユーザーを自動的にアプリケーショングループに入れるようにプラグインに指示することができます。

そして、 searchGroupFilter に、ユーザーのグループを取得するためのldapクエリを指定します。

例えば、 searchGroupFilter="(&(objectClass=posixGroup)(member=%%USERDN%%))"

%%USERDN%% がユーザーdnに置き換えられます。%%LOGIN%% は、ログインに置き換えられます。また、 %% の間で searchAttributes に指定したldapの属性を使用することもできます。例えば、 searchGroupFilter="(&(objectClass=posixGroup)(member=%%givenName%%))"

警告: searchGroupFilter を設定すると、ldap グループにマッチしない他のアプリケーショングループからユーザーが削除されます。グループを同期させたくない場合は、 searchGroupFilter を空にしてください。

searchGroupProperty では、グループ名を含むldap属性を指定する必要があります。例:searchGroupProperty="cn"。

また、検索のベースとなるDNを`searchGroupBaseDN`に指定することもできます。例: searchGroupBaseDN="ou=Groups,dc=Acme,dc=pt"

デバッグ

If the authentication does not working, you can have more details on what is wrong. To see these details, you should activate the traces for multiauth.

var/config/localconfig.ini.phpで、以下のパラメータを設定します。

[logger]
auth=file

[fileLogger]
auth=auth.log

そうすると、var/log/auth.logにはldapコネクタからのメッセージがいくつか残ります。auth.logファイルが肥大化しないように、必要のないときはこれらの設定を削除してください。