Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
centos:mail_c7:dovecot_6 [28.07.2014 20:29. ] – [auth-sql.conf.ext] django | centos:mail_c7:dovecot_6 [18.11.2024 07:08. ] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
====== Dovecot, Authentifizierung(en) ====== | ====== Dovecot, Authentifizierung(en) ====== | ||
{{: | {{: | ||
+ | ===== Authentifizierungsdaten ===== | ||
+ | Beim Betrieb unseres Dovecot-Mailservers sind wir auf folgende Daten angewiesen: | ||
+ | - **Username** : Der Username ist der Name, mit dem sich der Nutzer an unserem Mailserver anmeldet. Dies ist mindestens ein Username oder besser noch die eMail-Adresse des Endkunden, die dem Nutzerkonto primär zugewiesen ist. | ||
+ | - **Passwort** | ||
+ | - **UID** : User-ID, die beim Anlegen des Benutzerkontos, | ||
+ | - **GID** : Gruppen-ID, die beim Anlegen des Benutzerkontos, | ||
+ | - **Home-Verzeichnis**: | ||
+ | |||
===== Authentifizierungsquellen ===== | ===== Authentifizierungsquellen ===== | ||
Bei der Authentifizierungsquellen kennt **[[http:// | Bei der Authentifizierungsquellen kennt **[[http:// | ||
Zeile 16: | Zeile 24: | ||
- **Test**, zu Testzwecken. | - **Test**, zu Testzwecken. | ||
+ | ===== Authentifizierungs-Anfragen ===== | ||
+ | Authentifizierungs-Anfragen, | ||
+ | * **passdb-lookup** : Der passdb-lookup wird von Dovecot immer dann ausgeführt, | ||
+ | * **userdb-lookup** : Bei einem userdb-lookup ermittelt unser Dovecot-Server die Umgebungsvariablen des genannten/ | ||
Zeile 59: | Zeile 71: | ||
django: | django: | ||
- | Der Username **django** kann zwar benutzt werden, nicht aber django@nausch.org | + | Der Username **django** kann zwar benutzt werden, nicht aber django@nausch.org. |
Über die Konfigurationsdatei // | Über die Konfigurationsdatei // | ||
Zeile 234: | Zeile 246: | ||
Als einfache Lösung bietet sich nun die Datenhaltung in einer **[[centos: | Als einfache Lösung bietet sich nun die Datenhaltung in einer **[[centos: | ||
- | Die Definition des Mechanismus **SQL** wir über die Konfigurationsdatei //**/etc/dovecot/ | + | Das für die Anbindung an unseren [[|MySQL-Datenbankserver]] benötigte Dovecot-Modul, |
- | # | + | Falls wir das Paket noch nicht installiert haben, holen wir dies nun noch nach. |
- | <file bash vim / | + | # |
- | # | + | |
- | # < | + | |
- | passdb { | + | Was uns das Paket alles mitgebracht hat, können wir mit der Option // |
- | | + | # rpm -qil dovecot-mysql |
+ | < | ||
+ | Epoch : 1 | ||
+ | Version | ||
+ | Release | ||
+ | Architecture: | ||
+ | Install Date: Wed 30 Jul 2014 10:23:58 PM CEST | ||
+ | Group : System Environment/ | ||
+ | Size : 19536 | ||
+ | License | ||
+ | Signature | ||
+ | Source RPM : dovecot-2.2.13-2.el7.centos.src.rpm | ||
+ | Build Date : Wed 30 Jul 2014 06:02:59 PM CEST | ||
+ | Build Host : vml000200.dmz.nausch.org | ||
+ | Relocations : (not relocatable) | ||
+ | Packager | ||
+ | Vendor | ||
+ | URL : http:// | ||
+ | Summary | ||
+ | Description : | ||
+ | This package provides the MySQL back end for dovecot-auth etc. | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | </ | ||
- | # Path for SQL configuration file, see example-config/ | + | === dovecot-sql.conf.ext === |
- | args = / | + | Bei der RPM-Installation unseres Dovecot-Servers, |
- | } | + | # cp / |
- | # " | + | Die wichtigsten Konfigurationsparameter in dieser Datei, die wir unseren Bedürfnissen nach anpassen müssen sind: |
- | # needed information and there' | + | |
- | # < | + | |
- | #userdb { | + | * **//host//** Hostname oder IP-Adresse unsers mySQL-Datenbankservers |
- | # | + | * **// |
- | #} | + | * **//user//** Name unseres Datenbank-Nutzers |
- | + | * **//password// | |
- | userdb { | + | |
- | | + | * **//PLAIN//** Speicherung |
- | args = /etc/dovecot/dovecot-sql.conf.ext | + | * **//MD5-CRYPT//** Als mittlerweisen recht unsicher eingestufte MD5-Hashfunktion. |
- | } | + | * **//SHA256-CRYPT// |
- | + | * **//SHA512-CRYPT//** Sehr sichere kryptologischen Hashfunktionen. | |
- | # If you don't have any user-specific settings, you can avoid the user_query | + | * **//BLF-CRYPT//** Ein als sehr sicherer geltende Algorithmus Blowfish-Crypt. |
- | # by using userdb static instead of userdb sql, for example: | + | * **password_query** |
- | # <doc/wiki/UserDatabase.Static.txt> | + | * **user_query** |
- | #userdb { | + | |
- | | + | |
- | #args = uid=vmail gid=vmail home=/var/vmail/%u | + | |
- | #} | + | |
- | </file> | + | |
- | + | ||
- | Zur Aktivierung | + | |
- | # vim /etc/dovecot/conf.d/10-auth.conf | + | |
- | <file bash /etc/dovecot/conf.d/10-auth.conf> | + | |
- | + | ||
- | #!include auth-deny.conf.ext | + | |
- | #!include auth-master.conf.ext | + | |
- | + | ||
- | # Django | + | |
- | # default: !include auth-system.conf.ext | + | |
- | # Umstellung auf den Authentifizierungs-Mechanismus SQL | + | |
- | #!include auth-system.conf.ext | + | |
- | !include auth-sql.conf.ext | + | |
- | #!include auth-ldap.conf.ext | + | |
- | #!include auth-passwdfile.conf.ext | + | |
- | #!include auth-checkpassword.conf.ext | + | |
- | #!include auth-vpopmail.conf.ext | + | |
- | #!include auth-static.conf.ext | + | |
- | </ | + | |
- | In der Konfigurationsdatei // | + | In der Konfigurationsdatei // |
# vim / | # vim / | ||
<file bash / | <file bash / | ||
Zeile 367: | Zeile 377: | ||
# Django : 2013-02-06 | # Django : 2013-02-06 | ||
# default: # | # default: # | ||
- | default_pass_scheme = MD5-CRYPT | + | default_pass_scheme = PLAIN |
# passdb query to retrieve the password. It can return fields: | # passdb query to retrieve the password. It can return fields: | ||
Zeile 401: | Zeile 411: | ||
# Django : 2013-02-06 | # Django : 2013-02-06 | ||
# default: unset | # default: unset | ||
- | password_query = SELECT username AS user, password FROM mailbox WHERE username = ' | + | password_query = SELECT username AS user, password, 10000 AS userdb_uid, 10000 AS userdb_gid, \ |
+ | CONCAT(' | ||
# userdb query to retrieve the user information. It can return fields: | # userdb query to retrieve the user information. It can return fields: | ||
Zeile 424: | Zeile 435: | ||
# Django : 2013-02-06 | # Django : 2013-02-06 | ||
# default: unset | # default: unset | ||
- | user_query = SELECT CONCAT('/ | + | user_query = SELECT CONCAT('/ |
CONCAT(' | CONCAT(' | ||
Zeile 441: | Zeile 452: | ||
Den notwendigen Datenbank-Systemuser legen wir nun noch auf unserem mySQL-Datenbankserver an. | Den notwendigen Datenbank-Systemuser legen wir nun noch auf unserem mySQL-Datenbankserver an. | ||
- | === mySQL Datenbankuser anlegen === | ||
- | Wie Eingangs erwähnt, nutzen wir für die Verwaltung unserer Maildomänen und deren Nutzerkonten sowie Aliasen eine [[centos: | ||
+ | === mySQL Datenbankuser anlegen === | ||
+ | Wie bereits erwähnt, nutzen wir für die Verwaltung unserer Maildomänen und deren Nutzerkonten sowie Aliasen eine [[centos: | ||
Wir melden uns also als berechtigter Datenbankuser an der mySQL-Datenbank an. | Wir melden uns also als berechtigter Datenbankuser an der mySQL-Datenbank an. | ||
Zeile 491: | Zeile 502: | ||
Bye | Bye | ||
+ | === auth-sql.conf.ext === | ||
+ | Die Definition des Mechanismus **SQL** wir über die Konfigurationsdatei // | ||
+ | # vim / | ||
+ | <file bash vim / | ||
+ | # | ||
+ | # < | ||
+ | passdb { | ||
+ | driver = sql | ||
+ | # Path for SQL configuration file, see example-config/ | ||
+ | args = / | ||
+ | } | ||
+ | # " | ||
+ | # needed information and there' | ||
+ | # < | ||
+ | #userdb { | ||
+ | # driver = prefetch | ||
+ | #} | ||
+ | userdb { | ||
+ | driver = sql | ||
+ | args = / | ||
+ | } | ||
+ | # If you don't have any user-specific settings, you can avoid the user_query | ||
+ | # by using userdb static instead of userdb sql, for example: | ||
+ | # < | ||
+ | #userdb { | ||
+ | #driver = static | ||
+ | #args = uid=vmail gid=vmail home=/ | ||
+ | #} | ||
+ | </ | ||
+ | === Speicherung von Passwörtern === | ||
+ | Bevor wir uns nun an die Konfiguration der SQL-Unterstützung an unserem Dovecot machen, wollen wir uns noch kurz überlegen, wie wir die Passworte in der Datenbank ablegen. Die vermutlich vordergründigste, | ||
+ | # grep django /etc/shadow | ||
+ | | ||
+ | |||
+ | Will nun der Server bei der Anmeldung überprüfen benötigt er was? Genau das Passwort in Klartext! denn Nur so ist er in der Lage, den Passworthash des übermittelten Klartextpasswortes mit dem Hash in seiner Datenbank zu vergleichen. Ist nun jemand in der Lage die Übertragung zu kompromittieren, | ||
+ | |||
+ | Mit Hilfe von CRAM((**C**hallenge**R**esponse**A**uthentication**M**ethod)) haben wir nun ein Authentifizierungsverfahren an der Hand, mit der wir das Vorgenannte Problem mit der Übertragung eines Passwortes elegant umschiffen. Denn beim Anmeldevorgang erzeugt der Server bei der Clientanfrage einen individuellen Sitzungsschlüssel, | ||
+ | |||
+ | <WRAP round important> | ||
+ | |||
+ | Nur so ist sichergestellt, | ||
+ | |||
+ | === 10-auth.conf == | ||
+ | Zur Aktivierung des Authentifizierungs-Mechanismus **SQL** müssen wir nun nur noch den richtigen **!include** in der Konfigurationsdatei // | ||
+ | # vim / | ||
+ | <code bash>... | ||
+ | |||
+ | #!include auth-deny.conf.ext | ||
+ | #!include auth-master.conf.ext | ||
+ | |||
+ | # Django : 2014-07-30 | ||
+ | # default: !include auth-system.conf.ext | ||
+ | # Umstellung auf den Authentifizierungs-Mechanismus SQL | ||
+ | #!include auth-system.conf.ext | ||
+ | !include auth-sql.conf.ext | ||
+ | #!include auth-ldap.conf.ext | ||
+ | #!include auth-passwdfile.conf.ext | ||
+ | #!include auth-checkpassword.conf.ext | ||
+ | #!include auth-vpopmail.conf.ext | ||
+ | #!include auth-static.conf.ext | ||
+ | </ | ||
+ | |||
+ | Ferner definieren wir in der // | ||
+ | # vim / | ||
+ | <code bash>... | ||
+ | |||
+ | # Space separated list of wanted authentication mechanisms: | ||
+ | # plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey | ||
+ | # | ||
+ | # NOTE: See also disable_plaintext_auth setting. | ||
+ | # Django : 2014-05-23 | ||
+ | # default: auth_mechanisms = plain | ||
+ | auth_mechanisms = plain login digest-md5 cram-md5 | ||
+ | |||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Somit ergibt sich folgende komplette Konfigurationsdatei | ||
+ | # vim / | ||
+ | <file bash / | ||
+ | ## Authentication processes | ||
+ | ## | ||
+ | |||
+ | # Disable LOGIN command and all other plaintext authentications unless | ||
+ | # SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP | ||
+ | # matches the local IP (ie. you're connecting from the same computer), the | ||
+ | # connection is considered secure and plaintext authentication is allowed. | ||
+ | # See also ssl=required setting. | ||
+ | # | ||
+ | |||
+ | # Authentication cache size (e.g. 10M). 0 means it's disabled. Note that | ||
+ | # bsdauth, PAM and vpopmail require cache_key to be set for caching to be used. | ||
+ | # | ||
+ | # Time to live for cached data. After TTL expires the cached record is no | ||
+ | # longer used, *except* if the main database lookup returns internal failure. | ||
+ | # We also try to handle password changes automatically: | ||
+ | # authentication was successful, but this one wasn' | ||
+ | # For now this works only with plaintext authentication. | ||
+ | # | ||
+ | # TTL for negative hits (user not found, password mismatch). | ||
+ | # 0 disables caching them completely. | ||
+ | # | ||
+ | |||
+ | # Space separated list of realms for SASL authentication mechanisms that need | ||
+ | # them. You can leave it empty if you don't want to support multiple realms. | ||
+ | # Many clients simply use the first one listed here, so keep the default realm | ||
+ | # first. | ||
+ | # | ||
+ | |||
+ | # Default realm/ | ||
+ | # SASL realms and appending @domain to username in plaintext logins. | ||
+ | # | ||
+ | |||
+ | # List of allowed characters in username. If the user-given username contains | ||
+ | # a character not listed in here, the login automatically fails. This is just | ||
+ | # an extra check to make sure user can't exploit any potential quote escaping | ||
+ | # vulnerabilities with SQL/LDAP databases. If you want to allow all characters, | ||
+ | # set this value to empty. | ||
+ | # | ||
+ | |||
+ | # Username character translations before it's looked up from databases. The | ||
+ | # value contains series of from -> to characters. For example "# | ||
+ | # that '#' | ||
+ | # | ||
+ | |||
+ | # Username formatting before it's looked up from databases. You can use | ||
+ | # the standard variables here, eg. %Lu would lowercase the username, %n would | ||
+ | # drop away the domain if it was given, or " | ||
+ | # " | ||
+ | # | ||
+ | |||
+ | # If you want to allow master users to log in by specifying the master | ||
+ | # username within the normal username string (ie. not using SASL mechanism' | ||
+ | # support for it), you can specify the separator character here. The format | ||
+ | # is then < | ||
+ | # separator, so that could be a good choice. | ||
+ | # | ||
+ | |||
+ | # Username to use for users logging in with ANONYMOUS SASL mechanism | ||
+ | # | ||
+ | |||
+ | # Maximum number of dovecot-auth worker processes. They' | ||
+ | # blocking passdb and userdb queries (eg. MySQL and PAM). They' | ||
+ | # automatically created and destroyed as needed. | ||
+ | # | ||
+ | |||
+ | # Host name to use in GSSAPI principal names. The default is to use the | ||
+ | # name returned by gethostname(). Use " | ||
+ | # entries. | ||
+ | # | ||
+ | |||
+ | # Kerberos keytab to use for the GSSAPI mechanism. Will use the system | ||
+ | # default (usually / | ||
+ | # the auth service to run as root to be able to read this file. | ||
+ | # | ||
+ | |||
+ | # Do NTLM and GSS-SPNEGO authentication using Samba' | ||
+ | # ntlm_auth helper. < | ||
+ | # | ||
+ | |||
+ | # Path for Samba' | ||
+ | # | ||
+ | |||
+ | # Time to delay before replying to failed authentications. | ||
+ | # | ||
+ | |||
+ | # Require a valid SSL client certificate or the authentication fails. | ||
+ | # | ||
+ | |||
+ | # Take the username from client' | ||
+ | # X509_NAME_get_text_by_NID() which returns the subject' | ||
+ | # CommonName. | ||
+ | # | ||
+ | |||
+ | # Space separated list of wanted authentication mechanisms: | ||
+ | # plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp skey | ||
+ | # | ||
+ | # NOTE: See also disable_plaintext_auth setting. | ||
+ | # Django : 2014-05-23 | ||
+ | # default: auth_mechanisms = plain | ||
+ | auth_mechanisms = plain login digest-md5 cram-md5 | ||
+ | |||
+ | ## | ||
+ | ## Password and user databases | ||
+ | ## | ||
+ | |||
+ | # | ||
+ | # Password database is used to verify user's password (and nothing more). | ||
+ | # You can have multiple passdbs and userdbs. This is useful if you want to | ||
+ | # allow both system users (/ | ||
+ | # duplicating the system users into virtual database. | ||
+ | # | ||
+ | # < | ||
+ | # | ||
+ | # User database specifies where mails are located and what user/group IDs | ||
+ | # own them. For single-UID configuration use " | ||
+ | # | ||
+ | # < | ||
+ | |||
+ | #!include auth-deny.conf.ext | ||
+ | #!include auth-master.conf.ext | ||
+ | |||
+ | # Django : 2014-07-30 | ||
+ | # default: !include auth-system.conf.ext | ||
+ | # Umstellung auf den Authentifizierungs-Mechanismus passwd-file | ||
+ | #!include auth-system.conf.ext | ||
+ | !include auth-sql.conf.ext | ||
+ | #!include auth-ldap.conf.ext | ||
+ | #!include auth-passwdfile.conf.ext | ||
+ | #!include auth-checkpassword.conf.ext | ||
+ | #!include auth-vpopmail.conf.ext | ||
+ | #!include auth-static.conf.ext | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Testen der Authentifizierung ===== | ||
+ | Mit Hilfe des Befehls **doveadm** können wir sowohl den **// | ||
+ | |||
+ | Die Benutzereingaben sind in der Farbe < | ||
+ | |||
+ | Mit **// | ||
+ | < | ||
+ | <font style=" | ||
+ | </ | ||
+ | < | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | extra fields: | ||
+ | user=django@nausch.org</ | ||
+ | </ | ||
+ | |||
+ | Beim **// | ||
+ | < | ||
+ | <font style=" | ||
+ | </ | ||
+ | < | ||
+ | <font style=" | ||
+ | uid 10000 | ||
+ | gid 10000 | ||
+ | home / | ||
+ | mail</ | ||
+ | |||
+ | |||
+ | |||
+ | Haben wir die Benutzerauthentifizierung erfolgreich abgeschlossen, | ||
====== Links ====== | ====== Links ====== | ||
Zeile 503: | Zeile 759: | ||
* **[[wiki: | * **[[wiki: | ||
* **[[http:// | * **[[http:// | ||
- | |||
- | ~~DISCUSSION~~ | ||