Mediawiki an der AD über LDAP: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| (22 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 5: | Zeile 5: | ||
* Notiere dir die Details des LDAP-Servers: | * Notiere dir die Details des LDAP-Servers: | ||
** Domain Controller: '''win2022.lab34.linuggs.de''' | ** Domain Controller: '''win2022.lab34.linuggs.de''' | ||
| − | ** LDAP-Gruppe: ''' | + | ** LDAP-Gruppe: '''gg_wiki''' |
** Dienstbenutzer: '''mediawiki''' | ** Dienstbenutzer: '''mediawiki''' | ||
** Passwort: '''123Start$''' | ** Passwort: '''123Start$''' | ||
| Zeile 15: | Zeile 15: | ||
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPProvider | git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPProvider | ||
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPAuthentication2 | git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPAuthentication2 | ||
| + | git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PluggableAuth | ||
| + | git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPAuthorization | ||
| + | git clone https://gerrit.wikimedia.org/r/mediawiki/extensions//LDAPUserInfo | ||
| + | |||
</syntaxhighlight> | </syntaxhighlight> | ||
* Füge die folgenden Zeilen zur '''LocalSettings.php''' hinzu: | * Füge die folgenden Zeilen zur '''LocalSettings.php''' hinzu: | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
| − | + | # Add more configuration options below. | |
| − | + | $wgGroupPermissions['*']['read'] = true; | |
| − | + | $wgGroupPermissions['*']['autocreateaccount'] = true; | |
| + | |||
| + | |||
| + | // === LDAP-Erweiterungen laden === | ||
| + | wfLoadExtension('LDAPProvider'); | ||
| + | wfLoadExtension('PluggableAuth'); | ||
| + | wfLoadExtension('LDAPAuthentication2'); | ||
| + | wfLoadExtension('LDAPAuthorization'); | ||
| + | |||
| + | // === LDAP-Konfiguration festlegen === | ||
| + | $LDAPProviderDomainConfigs = "/var/www/html/ldap.json"; // Pfad zu ldap.json | ||
| + | $wgLDAPDomainNames = ['lab34.linuggs.de']; // Die Domain, die in ldap.json verwendet wird | ||
| + | $wgPluggableAuth_EnableLocalLogin = true; | ||
| + | |||
| + | // PluggableAuth-Konfiguration | ||
| + | $wgPluggableAuth_Config['lab34.linuggs.de'] = [ | ||
| + | 'plugin' => 'LDAPAuthentication2', | ||
| + | 'data' => [ | ||
| + | 'domain' => 'lab34.linuggs.de' | ||
| + | ] | ||
| + | ]; | ||
| + | |||
| + | // === Debugging aktivieren === | ||
| + | $wgShowExceptionDetails = true; | ||
| + | $wgDebugLogGroups['LDAP'] = '/var/www/html/LDAP.log'; | ||
| + | $wgDebugLogGroups['PluggableAuth'] = '/var/www/html/LDAP.log'; | ||
| + | $wgDebugLogGroups['LDAPAuthentication2'] = '/var/www/html/LDAP.log'; | ||
| + | $wgDebugLogGroups['LDAPAuthorization'] = '/var/www/html/LDAP.log'; | ||
| + | |||
| + | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Zeile 30: | Zeile 63: | ||
* Füge die Details des LDAP-Servers in der Datei '''ldap.json''' hinzu: | * Füge die Details des LDAP-Servers in der Datei '''ldap.json''' hinzu: | ||
<syntaxhighlight lang="json"> | <syntaxhighlight lang="json"> | ||
| − | + | { | |
| − | + | "lab34.linuggs.de": { | |
| − | + | "connection": { | |
| − | + | "server": "win2022.lab34.linuggs.de", | |
| − | + | "port": "389", | |
| − | + | "use-tls": "false", | |
| − | + | "user": "cn=mediawiki,cn=users,dc=lab34,dc=linuggs,dc=de", | |
| − | + | "pass": "12345-Xinux", | |
| − | + | "enctype": "clear", | |
| − | + | "options": { | |
| − | + | "LDAP_OPT_DEREF": 1 | |
| − | + | }, | |
| − | + | "basedn": "dc=lab34,dc=linuggs,dc=de", | |
| − | + | "userbasedn": "dc=lab34,dc=linuggs,dc=de", | |
| − | + | "groupbasedn": "dc=lab34,dc=linuggs,dc=de", | |
| − | + | "searchattribute": "sAMAccountName", | |
| − | + | "usernameattribute": "cn", | |
| − | + | "realnameattribute": "cn", | |
| − | + | "emailattribute": "mail", | |
| − | + | "grouprequest": "MediaWiki\\Extension\\LDAPProvider\\UserGroupsRequest\\UserMemberOf::factory", | |
| − | + | "presearchusernamemodifiers": ["spacestounderscores", "lowercase"] | |
| − | + | }, | |
| − | + | "authorization": { | |
| − | + | "rules": { | |
| − | + | "groups": { | |
| − | + | "required": ["cn=gg_wiki,cn=users,dc=lab34,dc=linuggs,dc=de"] | |
| + | } | ||
} | } | ||
| + | } | ||
} | } | ||
| − | + | } | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Testen der Verbindung === | === Testen der Verbindung === | ||
* Melde dich nach dem Speichern der Änderungen und einem Neustart des Webservers mit einem Benutzer aus der Gruppe '''lg_wiki''' an. | * Melde dich nach dem Speichern der Änderungen und einem Neustart des Webservers mit einem Benutzer aus der Gruppe '''lg_wiki''' an. | ||
| + | ==Sicherheit== | ||
| + | *ldap.json kann über den Browser ausgelesen werden. | ||
| + | *ldap Verbindung nicht verschlüsselt. | ||
| + | *http nicht verschlüsselt. | ||
| − | == | + | ==ldap.json kann über den Browser ausgelesen werden== |
| − | * | + | *'''mv /var/www/html/ldap.json /etc/ldap''' |
| − | + | *Ändern in LocalSettings.php | |
| − | + | $LDAPProviderDomainConfigs = "/etc/ldap/ldap.json"; | |
| − | + | ==ldap Verbindung nicht verschlüsselt== | |
| − | + | *Wir brauchen das root-ca der Domain | |
| − | + | *[[Microsoft Zertifizierungstelle]] | |
| + | ;Zertifikat einbauen unter Linux | ||
| + | *cp lab34-ca.cer /usr/local/share/ca-certificates/lab34-ca.crt | ||
| + | *sudo update-ca-certificates | ||
| + | ;Test ob das Zertifikat zieht | ||
| + | *openssl s_client -port 636 -CAfile lab34-ca.cer -host win2022.lab34.linuggs.de | ||
| + | ;Test ob das Zertifikat, mit eingebauten root-ca zieht | ||
| + | *openssl s_client -port 636 -host win2022.lab34.linuggs.de | ||
| + | ;/etc/ldap/ldap.conf anpassen | ||
| + | BASE dc=lab34,dc=linuggs,dc=de | ||
| + | URI ldaps://win2022.lab34.linuggs.de | ||
| + | LDAPDEBUG 1 | ||
| + | TLS_CACERT /etc/ssl/certs/ca-certificates.crt | ||
| + | ;Änderungen in der /etc/ldap/ldap.json | ||
| + | "port": "636", | ||
| + | "enctype": "ssl", | ||
Aktuelle Version vom 5. Oktober 2024, 08:06 Uhr
MediaWiki an LDAP (Active Directory) anbinden
Vorbereitung
- Stelle sicher, dass das PHP LDAP-Modul auf dem Webserver installiert ist: `php-ldap`.
- Notiere dir die Details des LDAP-Servers:
- Domain Controller: win2022.lab34.linuggs.de
- LDAP-Gruppe: gg_wiki
- Dienstbenutzer: mediawiki
- Passwort: 123Start$
Installation der MediaWiki LDAP-Extensions
- Lade die Erweiterungen „LDAPProvider“ und „LDAPAuthentication2“ herunter und installiere sie:
cd /var/www/html/extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPProvider
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPAuthentication2
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PluggableAuth
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LDAPAuthorization
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions//LDAPUserInfo
- Füge die folgenden Zeilen zur LocalSettings.php hinzu:
# Add more configuration options below.
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['autocreateaccount'] = true;
// === LDAP-Erweiterungen laden ===
wfLoadExtension('LDAPProvider');
wfLoadExtension('PluggableAuth');
wfLoadExtension('LDAPAuthentication2');
wfLoadExtension('LDAPAuthorization');
// === LDAP-Konfiguration festlegen ===
$LDAPProviderDomainConfigs = "/var/www/html/ldap.json"; // Pfad zu ldap.json
$wgLDAPDomainNames = ['lab34.linuggs.de']; // Die Domain, die in ldap.json verwendet wird
$wgPluggableAuth_EnableLocalLogin = true;
// PluggableAuth-Konfiguration
$wgPluggableAuth_Config['lab34.linuggs.de'] = [
'plugin' => 'LDAPAuthentication2',
'data' => [
'domain' => 'lab34.linuggs.de'
]
];
// === Debugging aktivieren ===
$wgShowExceptionDetails = true;
$wgDebugLogGroups['LDAP'] = '/var/www/html/LDAP.log';
$wgDebugLogGroups['PluggableAuth'] = '/var/www/html/LDAP.log';
$wgDebugLogGroups['LDAPAuthentication2'] = '/var/www/html/LDAP.log';
$wgDebugLogGroups['LDAPAuthorization'] = '/var/www/html/LDAP.log';
LDAP-Konfiguration in MediaWiki
- Lege eine Konfigurationsdatei für die LDAP-Anbindung an:
/var/www/html/extensions/LDAPProvider/ldap.json
- Füge die Details des LDAP-Servers in der Datei ldap.json hinzu:
{
"lab34.linuggs.de": {
"connection": {
"server": "win2022.lab34.linuggs.de",
"port": "389",
"use-tls": "false",
"user": "cn=mediawiki,cn=users,dc=lab34,dc=linuggs,dc=de",
"pass": "12345-Xinux",
"enctype": "clear",
"options": {
"LDAP_OPT_DEREF": 1
},
"basedn": "dc=lab34,dc=linuggs,dc=de",
"userbasedn": "dc=lab34,dc=linuggs,dc=de",
"groupbasedn": "dc=lab34,dc=linuggs,dc=de",
"searchattribute": "sAMAccountName",
"usernameattribute": "cn",
"realnameattribute": "cn",
"emailattribute": "mail",
"grouprequest": "MediaWiki\\Extension\\LDAPProvider\\UserGroupsRequest\\UserMemberOf::factory",
"presearchusernamemodifiers": ["spacestounderscores", "lowercase"]
},
"authorization": {
"rules": {
"groups": {
"required": ["cn=gg_wiki,cn=users,dc=lab34,dc=linuggs,dc=de"]
}
}
}
}
}
Testen der Verbindung
- Melde dich nach dem Speichern der Änderungen und einem Neustart des Webservers mit einem Benutzer aus der Gruppe lg_wiki an.
Sicherheit
- ldap.json kann über den Browser ausgelesen werden.
- ldap Verbindung nicht verschlüsselt.
- http nicht verschlüsselt.
ldap.json kann über den Browser ausgelesen werden
- mv /var/www/html/ldap.json /etc/ldap
- Ändern in LocalSettings.php
$LDAPProviderDomainConfigs = "/etc/ldap/ldap.json";
ldap Verbindung nicht verschlüsselt
- Wir brauchen das root-ca der Domain
- Microsoft Zertifizierungstelle
- Zertifikat einbauen unter Linux
- cp lab34-ca.cer /usr/local/share/ca-certificates/lab34-ca.crt
- sudo update-ca-certificates
- Test ob das Zertifikat zieht
- openssl s_client -port 636 -CAfile lab34-ca.cer -host win2022.lab34.linuggs.de
- Test ob das Zertifikat, mit eingebauten root-ca zieht
- openssl s_client -port 636 -host win2022.lab34.linuggs.de
- /etc/ldap/ldap.conf anpassen
BASE dc=lab34,dc=linuggs,dc=de URI ldaps://win2022.lab34.linuggs.de LDAPDEBUG 1 TLS_CACERT /etc/ssl/certs/ca-certificates.crt
- Änderungen in der /etc/ldap/ldap.json
"port": "636", "enctype": "ssl",