LDAP認証
LDAPを使用する利点は、すべてのユーザーとグループの情報を、集中管理された1つのサーバーに置くことができることです。
まず最初にすることは、Linuxシステムにphp ldap extensionをインストールすることです。
apt install php7.4-ldap
Then, in order to enable the LDAP support Lizmap, you have to change the authentication method in the configuration as follows.
Enabling LDAP
You have to enable the module ldapdao with this command
php lizmap/install/configurator.php ldapdao
Then you have to add a section [ldap:lizmapldap] into your profiles.ini.php, with some settings that allow to connect to your ldap server, and to search users into the ldap. The section may already exist if you copied profiles.ini.php from the profiles.ini.php.dist.
[ldap:lizmapldap]
hostname=localhost
port=389
adminUserDn="cn=admin,ou=lizmap,dc=com"
adminPassword=""
searchUserBaseDN="dc=XY,dc=fr"
searchUserFilter="(&(objectClass=posixAccount)(uid=%%LOGIN%%))"
bindUserDN="uid=%?%,ou=users,dc=XY,dc=fr"
searchAttributes="uid:login,givenName:firstname,sn:lastname,mail:email,organization:organization,street:street,postcode:postcode,city:city"
searchGroupFilter=
searchGroupProperty="cn"
searchGroupBaseDN=""
これらのパラメータの設定方法については、以下のセクションで詳しく説明しています。
To finish to enable the module, run php lizmap/install/installer.php
ldap settings
ユーザーデータの設定プロパティ
パスワードを確認したり、ユーザーが初めて認証したときに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. It builds the DN from a "template" indicated into the bindUserDN property, and from various data. These data can be the given login or one of the ldap attributes of the user.
Building the DN from the login given by the user: bindUserDN should contain a DN, with a
%%LOGIN%%placeholder that will be replaced by the login.Example:
bindUserDN="uid=%%LOGIN%%,ou=users,dc=XY,dc=fr". If the user give john.smith as a login, the authentication will be made with the DNbindUserDN="uid=john.smith,ou=users,dc=XY,dc=fr".For some LDAP, the DN could be a simple string, for example an email. You could then set
bindUserDN="%%LOGIN%%@company.local". Or evenbindUserDN="%%LOGIN%%"if the login can type the full value of the DN or an email or else.. (Probably it's not recommended to allow a user to type himself its full DN, it can be a security issue)Building the DN from one of the ldap attributes of the user. In this case, the plugin will first query the ldap directory with the searchUserFilter filter, to retrieve the user's ldap attributes. Then, in bindUserDN, you can indicate a DN where some values will be replaced by some attributes values, or you can indicate a single attribute name, corresponding to an attribute that contain the full DN of the user.
For the first case, bindUserDn should contain a DN, with some
%?%placeholders that will be replaced by corresponding attributes value. Example:bindUserDN="uid=%?%,ou=users,dc=XY,dc=fr". Here it replaces the%?%by the value of the uid attribute readed from the user's attributes. The attribute name should be present into the searchAttributes configuration property, even with no field mapping. Ex:...,uid:,.... See above.For the second case, just indicate the attribute name, prefixed with a $. Example:
bindUserDN="$dn". Here it takes the dn attribute readed from the search, and use its full value as the DN to login against the ldap server. It is useful for some LDAP server like sometimes Active Directory that need a full DN specific for each user. The attribute name should be present into the searchAttributes configuration property, even with no field mapping. Ex:...,dn:,.... See above.
Note that you can indicate several dn templates, if you have
complex ldap structure. Use [] to indicate an item list:
bindUserDN[]="uid=%?%,ou=users,dc=XY,dc=fr"
bindUserDN[]="cn=%?%,ou=users,dc=XY,dc=fr"
ユーザー権限の設定プロパティ
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 ldapdao.
var/config/localconfig.ini.phpで、以下のパラメータを設定します。
[logger]
auth=file
[fileLogger]
auth=auth.log
そうすると、var/log/auth.logにはldapコネクタからのメッセージがいくつか残ります。auth.logファイルが肥大化しないように、必要のないときはこれらの設定を削除してください。