<div dir="auto"><div style="font-family:sans-serif;font-size:12.8px" dir="auto"><div style="width:361.091px;margin:16px 0px"><div>Hi there,<br><br>Although I have set up TLS in my Dovecot installation, I would like to<br>also set up some non-plaintext authentication mechanism, specifically<br>CRAM-MD5 and SCRAM-SHA-1.<br><br>As I read in the documents, "The problem with non-plaintext auth<br>mechanisms is that the password must be stored either in plaintext, or<br>using a mechanism-specific scheme that’s incompatible with all other<br>non-plaintext mechanisms".<br><br>I will not be storing the user's passwords in plaintext, so I will have<br>to use different mechanism-specific hash schemes. I was wondering<br>whether it would be possible to have several auth databases, one for<br>each non-plaintext mechanism. Well, in reality, I will have just one<br>database with multiple hashes: SHA512-CRYPT, CRAM-MD5 and SCRAM-SHA-1<br>but then I am going to set up three different passdb instances in<br>dovecot, each one with its own SQL configuration.<br><br>For example:<br><br>passdb {<br>   driver = sql<br>   args = /etc/dovecot/dovecot-sql-plain.conf.ext<br>}<br><br>passdb {<br>   driver = sql<br>   args = /etc/dovecot/dovecot-sql-cram-md5.conf.ext<br>}<br><br>passdb {<br>   driver = sql<br>   args = /etc/dovecot/dovecot-sql-scram-sha-1.conf.ext<br>}<br><br>Most users would use TLS and PLAIN as authentication mechanism so the<br>last two password databases will not be used at all. However, those<br>users using CRAM-MD5 or SCRAM-SHA-1 would try the other databases.<br><br>My users table would be somewhat like this:<br><br>  CREATE TABLE users (<br>      username VARCHAR(128) NOT NULL,<br>      domain VARCHAR(128) NOT NULL,<br>      password VARCHAR(77) NOT NULL,<br>      password_cram_md5 VARCHAR(74) NOT NULL,<br>      password_scram_sha_1 VARCHAR(100) NOT NULL,<br>      home VARCHAR(255) NOT NULL,<br>      uid INTEGER NOT NULL,<br>      gid INTEGER NOT NULL,<br>      active CHAR(1) DEFAULT 'Y' NOT NULL<br>  );<br><br>username: <a href="mailto:foo@bar.com" style="text-decoration-line:none;color:rgb(66,133,244)">foo@bar.com</a><br>domain: <a href="http://bar.com/" style="text-decoration-line:none;color:rgb(66,133,244)">bar.com</a><br>password: {SHA512-CRYPT}$6$Mih5.y90z...CqxX2LxfMJMqoC42NvBK1<br>password_cram_md5: {CRAM-MD5}a457...2a74f63442e7473e9576cf2e<br>password_scram_sha_1: {SCRAM-SHA-1}4096,4...9AYjadouwXqiqc3UM=<br><br>Obviously, the SQL query in each dovecot-sql-....ext file would be<br>different. For instance:<br><br>/etc/dovecot/dovecot-sql-plain.conf.ext<br>default_pass_scheme = SHA512-CRYPT<br>password_query = \<br>   SELECT username, domain, password, home AS userdb_home, uid AS<br>userdb_uid FROM users WHERE username = '%n' AND domain = '%d'<br><br>/etc/dovecot/dovecot-sql-cram-md5.conf.ext<br>default_pass_scheme = CRAM-MD5<br>password_query = \<br>   SELECT username, domain, password_cram_md5 AS password, home AS<br>userdb_home, uid AS userdb_uid FROM users WHERE username = '%n' AND<br>domain = '%d'<br><br>/etc/dovecot/dovecot-sql-scram-sha-1.conf.ext<br>default_pass_scheme = SCRAM-SHA-1<br>password_query = \<br>   SELECT username, domain, password_scram_sha_1 AS password, home AS<br>userdb_home, uid AS userdb_uid FROM users WHERE username = '%n' AND<br>domain = '%d'<br><br>Could you please tell me whether this set up would work? Do you believe<br>is worth the complexity or maybe I had better keep it more simple and<br>use just PLAIN auth with TLS?<br><br>Cheers,<br>Jesús Ángel<br><br></div></div><div style="height:0px"></div></div><br></div>