Commit Graph
46 Commits
Author SHA1 Message Date
Copilot ae7339afd4 Use native booleans for prepared SQL params; stop binding db_get_boolean() values (#1019)
Prepared statements were binding DB-specific boolean literals (`'t'/'f'`) produced by `db_get_boolean()`, which breaks PostgreSQL parameter typing in some paths (notably mailbox creation via handler flows). 

This change standardizes bound boolean parameters to native PHP `true`/`false` (which are then cast to 0/1 which seems to work fine within PDO/PostgreSQL).

fixes https://github.com/postfixadmin/postfixadmin/issues/1017
2026-04-23 19:28:01 +01:00
Kent Riboe 2c0a06f932 Add Exec class to help refactor/reduce duplication of proc_open calls, update phpunit (see note) (#1009)
* code refactoring (adds Exec class to centralise proc_open like calls). 
* bump phpunit to ^11.0, as this is the last release that supports php8.2. Note, there is not (yet?) a phpunit release for php8.2 that fixes PKSA-z3gr-8qht-p93v or PKSA-5jz8-6tcw-pbk4, so ignore them for now in composer.json
2026-04-18 10:05:35 +01:00
David Goodwin 8a1f9a11af CSRF protection - support multiple tokens (#985)
possible fix for https://github.com/postfixadmin/postfixadmin/issues/967

CSRF Token changes : rather than have one PFA_Token value in $_SESSION, store a list of them, where each value has a time stamp it was issued on. The aim is to allow the user to have multiple browser tabs open at once - and not have the last tab that loaded trample on others. Tokens expire after 1 hour.

Adds a Smarty helper function `{CSRF_Token}` which will output `<input type=hidden name=CSRF_Token value=asdf123>` or `{CSRF_Token type=url}` which outputs a literal string like 'asdf123' suitable for placing in a URL.

Adds a PHP exception handler in public/common.php, which could be used to display a more friendly error message/response (but at the moment is fairly minimal).

Removes most uses of `die()` within the codebase, and instead moves to throw an exception
2026-03-01 19:30:16 +00:00
David Goodwin b092017f9b be more explict over what types class properties should be 2026-01-28 09:50:26 +00:00
David Goodwin 52794bede7 misc fixes for psalm after allowing it to be updated 2026-01-28 09:50:26 +00:00
David Goodwin 798e8b269c Topt app passwords fixes (WIP) (#805)
various improvements to the TOTP code see also:  #802
2025-05-16 20:31:20 +01:00
Shao Yu-Lung (Allen) 0876c368e4 feat: support Dovecot DIGEST-MD5 (#816)
Add support for dovecot DIGEST-MD5 auth (using : $CONF['pacrypt'] = 'dovecot:DIGEST-MD5') 

This also changes the pacrypt() function to take an optional 3rd argument (username). 
Thanks @bestlong
2024-04-12 09:57:19 +01:00
David Goodwin dc792a0222 add unit test to cover some of Login::addAppPassword() 2023-12-27 16:17:55 +00:00
David Goodwin 015d4ec9cd reindent / reformat; add type hints for some of the app password stuff; try and make sure someone can only remove their own app password (see revokeAppPassword() ) 2023-12-23 21:43:31 +00:00
David Goodwin 4d17aa6ef9 manaul merge in of verdigado:master (see #753) (MFA/TOTP support) 2023-12-23 17:05:52 +00:00
David Goodwin 2d6ded2786 PSR2 -> PSR12 formatting 2022-06-28 13:46:11 +01:00
BotoX 768f2ee844 Improve dovecot mail-crypt postpassword script security (pipe password instead of passing on cmdline)
Suggested from: https://github.com/postfixadmin/postfixadmin/issues/441#issuecomment-774736944
2021-06-13 12:24:27 +02:00
David Goodwin 8518d53906 merge postfixadmin_3.3 into master 2021-05-13 13:15:27 +01:00
David Goodwin 584e4ef41d type hinting changes 2021-05-13 12:56:38 +01:00
Andrey Miroshnichenko 0ebb006888 Adds an ability to update password_expity field when user changes own password 2021-05-13 00:23:05 +03:00
David Goodwin 2edabc3e03 phpcs insists on some brace changes 2021-04-13 21:19:16 +01:00
David Goodwin 823f27b29d phpcs wants to change ... 2021-03-22 09:28:28 +00:00
Sven Seeberg 160fb32441 Change Login changePassword, fixes #456
* The db_udpate function already sets backticks around the table
  name, which results and error name if the string passed as argument
  for the table name already contains backticks.

Signed-off-by: Sven Seeberg <mail@sven-seeberg.de>
2021-02-19 08:58:08 +01:00
David Goodwin c755e82a36 Merge branch 'postfixadmin_3.3' 2021-02-18 12:12:27 +00:00
David Goodwin b2831d1241 psalm improvements 2021-02-17 21:29:18 +00:00
David Goodwin 237615502a Merge remote-tracking branch 'origin/postfixadmin_3.3' 2021-01-27 09:29:57 +00:00
David Goodwin 52933a6307 remove change to table_by_key() as the original bug has been found in Login 2021-01-26 21:06:15 +00:00
David Goodwin 84ad0ebec7 perhaps better error logging if mailbox_postpassword_script fails 2021-01-25 22:04:04 +00:00
David Goodwin 336259957d Merge remote-tracking branch 'origin/postfixadmin_3.3' 2021-01-25 21:58:31 +00:00
David Goodwin a442b7331d hint for future people 2021-01-25 17:00:16 +00:00
David Goodwin 481c465712 merge e7e1ce9c28 to fix PostgreSQL tests 2021-01-19 19:24:08 +00:00
David Goodwin e7e1ce9c28 fix postgresql test 2021-01-19 16:50:56 +00:00
David Goodwin dd7d94912b fix psalm issue(s); fix incorrect variable; throw exception if mailbox_postpassword_script fails 2021-01-15 19:26:07 +00:00
David Goodwin 70bf59edc4 composer format; fix syntax issue; comment out code in model/Login which fails psalm check 2021-01-14 22:22:27 +00:00
David Goodwin cb161a7cec Merge pull request #421 from BotoX/master-crypt
Suport for dovecot mail-crypt-plugin via new mailbox_postpassword_script hook
2021-01-14 20:11:14 +00:00
David Goodwin 79737bc049 reformat 2021-01-14 17:07:55 +00:00
David Goodwin ab56724a15 add hash_equals call 2021-01-14 17:07:55 +00:00
David Goodwin 85960b7096 more Login pacrypt() exception handling - see https://github.com/postfixadmin/postfixadmin/issues/420 2021-01-14 17:07:55 +00:00
David Goodwin 0a55868736 require a password to be non-empty on login 2021-01-14 17:07:55 +00:00
David Goodwin 30e3132a34 wrap pacrypt() call with a try/catch to log/handle issues where an exception is thrown - see https://github.com/postfixadmin/postfixadmin/issues/420 2021-01-14 17:07:55 +00:00
David Goodwin 18a019690c reformat 2021-01-14 11:26:04 +00:00
David Goodwin 2060422d9a add hash_equals call 2021-01-14 11:16:31 +00:00
David Goodwin 8b1adbcf1f more Login pacrypt() exception handling - see https://github.com/postfixadmin/postfixadmin/issues/420 2021-01-14 11:13:02 +00:00
David Goodwin 5827a12628 require a password to be non-empty on login 2021-01-13 22:46:33 +00:00
David Goodwin 72ded8494a wrap pacrypt() call with a try/catch to log/handle issues where an exception is thrown - see https://github.com/postfixadmin/postfixadmin/issues/420 2021-01-13 22:44:09 +00:00
BotoX c6ae3ea2f3 Suport for dovecot mail-crypt-plugin via new mailbox_postpassword_script hook.
Uses doveadm mailbox cryptokey on create user / password change to adjust user encryption key.
https://doc.dovecot.org/configuration_manual/mail_crypt_plugin/
2021-01-11 21:07:45 +01:00
David Goodwin b8fa60bb8a more type hints / psalm fixes 2020-09-28 20:33:54 +01:00
David Goodwin e4d5e4bee0 reformat 2020-09-26 09:58:16 +01:00
David Goodwin ce8c636eb5 rejig Login::__construct() as only one arg is really needed 2020-09-26 09:58:05 +01:00
David Goodwin 7107e17c4c composer format 2020-09-25 21:33:26 +01:00
David Goodwin f091948381 move password check and recovery code generation out of PFAHandlers and into a Login class 2020-09-25 21:32:03 +01:00