3. Dovecot¶
The next step is to configure the IMAP server dovecot to the device passwords application.
Connecting with telnet localhost 143 should result in a similar output similar to the following one:
* OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN] Dovecot ready.
On the database enable the pgcrypto extension:
Set configuration in dovecot/dovecot.conf and dovecot/dovecot-sql.conf.ext:
driver = pgsql
connect = host=postgres dbname=postgres user=postgres password=postgres
password_query = SELECT users.username as username, NULL AS password, 'Y' as nopassword FROM users LEFT OUTER JOIN tokens on users.sub = tokens.sub WHERE users.username = '%n' AND (expires IS NULL OR expires > NOW()) AND crypt('%w', REPLACE(tokens.token, '$2b$', '$2a$')) = REPLACE(tokens.token, '$2b$', '$2a$')
user_query = SELECT username FROM users WHERE username = '%n'
iterate_query = SELECT username FROM users
Restart the dovecot container to apply this configuration:
You are now able to log in using an IMAP client by using the devicee password.
How to integrate other applications?
If you use other applications in production, look at the guide on how to integrate applications.