PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
3.8 KiB

  1. # PostfixAdmin Password Hash Support.
  2. How are your passwords stored in the database.
  3. They should not be stored in plain text.
  4. Whatever format you choose will need to be supported by your IMAP server (and whatever provides SASL auth for Postfix)
  5. ## Configuration
  6. See config.inc.php - look for
  7. ```php
  8. $CONF['encrypt'] = 'something';
  9. ```
  10. ## Supported Formats
  11. This document is probably not complete.
  12. It possibly provides better documentation than was present before. This may not say much.
  13. ### cleartext
  14. No hashing. May be useful for debugging.
  15. Insecure. Try to avoid. May be useful for legacy purposes.
  16. ### mysql_encrypt
  17. Uses the MYSQL ENCRYPT() function (this uses 'crypt' underneath).
  18. Can be secure.
  19. Requires MySQL.
  20. Should use a sha512 salt for new values.
  21. ### md5crypt
  22. md5crypt = uses md5crypt() function - in a 'crypt' like format.
  23. e.g.
  24. `$1$c9809462$M0zeLuOvixH61C2csGN.U0`
  25. You should not use this for new installations
  26. (it probably does not offer a high level of security)
  27. ### md5
  28. PHP's md5() function.
  29. You should not use this (it does not offer a high level of security), but is probably better than cleartext.
  30. ### system
  31. Uses PHP's crypt function.
  32. Probably throws an E_NOTICE. Avoid?
  33. example : `$1$tWgqTIuF$1HFciCXrhVpACGjBMxNr/0`
  34. ### authlib
  35. See source code. Presumably useful for Courier based installations.
  36. #### With `$CONF['authlib_default_flavor'] = 'md5raw`;`
  37. might give something like :
  38. `{md5raw}3858f62230ac3c915f300c664312c63f`
  39. Based on md5, so avoid.
  40. #### With `$CONF['authlib_default_flavor'] = 'crypt`;`
  41. Uses PHP Crypt.
  42. `{crypt}blfqitzeBpyAE`
  43. Presumably weak.
  44. #### With `$CONF['authlib_default_flavor'] = 'SHA';`
  45. Uses sha1, base64 encoded. Unsalted. Avoid.
  46. ### dovecot:CRYPT-METHOD
  47. Uses dovecot binary to produce hash.
  48. Pros -
  49. * Minimal dependency on PostfixAdmin / PHP code.
  50. * Hash should definitely work with dovecot!
  51. Cons -
  52. * file permissions and/or execution of doveadm by the web server may be problematic.
  53. * requires: proc_open(...) - which might be blocked by e.g. safemode.
  54. * doveadm may not be installed.
  55. * possible issues with SELinux
  56. * See https://github.com/postfixadmin/postfixadmin/issues/398 (file permissions)
  57. #### Incomplete list of CRYPT-METHOD
  58. * CRAM-MD5
  59. * SHA
  60. * SHA1
  61. * SHA256
  62. * SHA512
  63. * CLEAR
  64. * CLEARTEXT
  65. * PLAIN
  66. * PLAIN-TRUNC
  67. If in doubt, try `dovecot:SHA512`
  68. Dovecot generated passwords in your database should look a bit like :
  69. `{SHA256}JMQi5oHxwb0IKGx6r10jpfCI3NsLIZgGs6nleSRPAMU=`
  70. If you have problems, start by checking you can generate one on the command line using e..g
  71. `doveadm pw -s SHA256`
  72. ### php_crypt
  73. Potentially the most secure.
  74. By default it will generate a SHA512 salt. Output in crypt format.
  75. Other methods :
  76. * BLOWFISH
  77. * SHA512
  78. * SHA256
  79. * DES (avoid)
  80. * MD5 (avoid)
  81. e.g.
  82. `$6$emcsNNrzGZSN64mI$A/bmacTGSp2UrdcPvaROrR2FPQS5KlnoU.a/0zmfpaubBO9o1ZcgyQIic4Qb59SMxA2H8YxgS1XILO1wZhjkZ0`
  83. You can specify the salting method using a :METHOD in the specification.
  84. e.g.
  85. `$CONF['encrypt'] = 'php_crypt:SHA512';`
  86. You can make the hashing more 'difficult' by specifying an additional parameter like :
  87. `$CONF['encrypt'] = 'php_crypt:SHA512:5000';`
  88. which should change the 'cost' (BLOWFISH) or rounds (SHA256, SHA512).
  89. finally you can ask that the generated hash has a specific prefix (e.g. {SHA512} ) like :
  90. `$CONF['encrypt'] = 'php_crypt:SHA512:5000:{SHA512-CRYPT}';`
  91. ### sha512.b64
  92. See https://github.com/postfixadmin/postfixadmin/issues/58
  93. No dovecot dependency; should support migration from md5crypt
  94. Output is base64 encoded i.e. a hash like :
  95. * `$6$emcsNNrzGZSN64mI$A/bmacTGSp2UrdcPvaROrR2FPQS5KlnoU.a/0zmfpaubBO9o1ZcgyQIic4Qb59SMxA2H8YxgS1XILO1wZhjkZ0`
  96. is base64 encoded into :
  97. * JDYkZW1jc05OcnpHWlNONjRtSSRBL2JtY...
  98. and then formatted to become :
  99. * {SHA512-CRYPT.B64}JDYkZW1jc05OcnpHWlNONjRtSSRBL2JtY....
  100. This format should support older passwords with a {MD5-CRYPT} prefix, to allow you to migrate.