Review main Merged

73832[FEATURE] Introduce TCA type "password"

Torben Hansen CR +2 V +2 Hard +596 −64 updated 03/26/22, 12:04

Commit message

In the process of using dedicated TCA types,
the new TCA type "password" is introduced and
replaces "eval=password" and "eval=saltedpassword"
of TCA type "input".

Notable changes to the previous behaviour:
- "trim" is always done in DataHandler and FormEngine
- Password field is rendered as input type=password
- The input field has by default "autocomplete=off"

The TCA type "password" introduces the new configuration
"hashed", which can be set to "false", if the field value
should be saved as plaintext to the database. This
configuration has no effect for the tables "fe_users" and
"be_users".

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Benni Mack +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 23

Show 3 more files

Review log 4160

Show 2435 earlier messages
  1. Torben Hansen uploaded patch set 1 03/06/22, 13:01

  2. Torben Hansen marked it work in progress 03/06/22, 13:03

  3. core-ci voted on patch set 1 V +1 03/06/22, 13:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24639

  4. Benni Mack commented on patch set 1 03/07/22, 18:15

    DataHandler.php:1828

    I think it is time to add this to our TCA instead of hard-coding it. "hashingAlgo" which allows a PHP class name, and we allow "FE" and "BE" as well.
  5. Torben Hansen commented on patch set 1 03/10/22, 10:32

    DataHandler.php:1828

    I see some problems if we make this too configurable. At least, for the tables fe_users and be_users, this must be fixed to either "FE" or "BE", since configured password hashing from TYPO3_CONF_VARS must be used and this is also hardcoded in several places in TYPO3 core (e.g. $saltFactory->get($currentPasswordHashed, 'BE') in ext:setup or in changePasswordAction() of ext:felogin). If we allow a PHP classname here, should we also allow to configure password hashing options like PasswordHashFactory does?
  6. Benni Mack commented on patch set 1 03/11/22, 07:49

    DataHandler.php:1828 Reply

    Good points, let us keep it as is for the time being!
  7. Torben Hansen rebased onto patch set 2 03/13/22, 12:42

  8. core-ci voted on patch set 2 V +1 03/13/22, 12:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24857

  9. Torben Hansen uploaded patch set 3 03/15/22, 18:57

  10. core-ci voted on patch set 3 V +1 03/15/22, 19:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24913

  11. Torben Hansen uploaded patch set 4 03/16/22, 08:03

  12. Torben Hansen marked it ready for review 03/16/22, 08:03

  13. Torben Hansen uploaded patch set 5 03/16/22, 08:05

  14. core-ci voted on patch set 4 V -1 03/16/22, 08:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24933

  15. core-ci voted on patch set 5 V -1 03/16/22, 08:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24934

  16. Torben Hansen uploaded patch set 6 03/16/22, 10:34

  17. core-ci voted on patch set 6 V +1 03/16/22, 10:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24941

  18. Torben Hansen commented on patch set 6 03/16/22, 11:07

    DataHandler.php:1828 Reply

    As discussed earlier, we leave this as it is.
  19. Oli Bartsch commented on patch set 6 03/16/22, 18:04

    Hi Torben, thanks for your patch. I did a first read and added some comments accordingly.

    PasswordElement.php:48

    Do those wizards make any sense at all? They will just display "*********".

    PasswordElement.php:83

    We might filter the list here since only "null" should be considered, see this patch https://review.typo3.org/c/Packages/TYPO3.CMS/+/73977 for reference.

    PasswordElement.php:87

    Shouldn't we use `<input type="password">` instead?

    PasswordElement.php:101

    This should always be done for this TCA type. Additionally, this should be removed from InputTextElement now.

    PasswordElement.php:141

    I think "is_in" shouldn't be supported

    PasswordElement.php:154

    This could then be customized (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password#allowing_autocomplete) once we are using "<input type=password".

    PasswordElement.php:205

    Those variables are superfluous, see https://review.typo3.org/c/Packages/TYPO3.CMS/+/73894.

    TcaColumnsProcessPlaceholders.php:24

    Do we need to adjust TcaInputPlaceholders as well?

    TcaRecordTitle.php:411

    This is now the same as `getRecordTitleForStandardTextField()`. However I would suggest we also replace the value with `*******` here? While it does not make much sense to use the password as record title at all, we should not expose the raw database value (no matter if hashed or not). See the usage in `getProcessedValue()` as example.

    BackendUtility.php:1681

    I don't see the benefit of the "random number". Should we just use a static number? IMO would make the UI more clear.

    DataHandler.php:86

    Do we need to adjust DataMapProcessor as well?

    DataHandler.php:1525

    The list is sorted alphabetically

    DataHandler.php:1807

    Let's just add parameters, we actually use.

    DataHandler.php:1823

    This should be done before the required check

    DataHandler.php:1826

    Could be simplified to: "!(tcaFieldConf['hashed'] ?? false)"

    DataHandler.php:1827

    Shouldn't we check more explicit here (table<=>fieldname)?

    Feature-97104-NewTCATypePassword.rst:29

    "max" is missing here

    Feature-97104-NewTCATypePassword.rst:41

    "max" is missing here.

    DataHandlerTest.php:223

    Is there a reason to remove this test? AFAICS the behaviour should still apply.
  20. Torben Hansen uploaded patch set 7 03/17/22, 19:14

  21. Torben Hansen commented on patch set 7 03/17/22, 19:14

    PasswordElement.php:48 Reply

    Yes, right. I'll remove them.

    PasswordElement.php:83 Reply

    Done

    PasswordElement.php:87 Reply

    See discussion here: https://typo3.slack.com/archives/C03AM9R17/p1645363953753829 I personally would go for input=password with autocomplete=off - this gives us the possibility to remove this line.

    PasswordElement.php:101 Reply

    Done

    PasswordElement.php:141 Reply

    Done

    PasswordElement.php:154 Reply

    See input type=password comment. Should we go for input=password?

    PasswordElement.php:205 Reply

    Done

    TcaColumnsProcessPlaceholders.php:24 Reply

    Yes, I think we should

    TcaRecordTitle.php:411 Reply

    Done

    BackendUtility.php:1681 Reply

    Agree, changed it to ********

    DataHandler.php:86 Reply

    If you mean getPrefixLanguageTitleFieldNames(), I think prefixLangTitle should not apply to password fields.

    DataHandler.php:1525 Reply

    Done

    DataHandler.php:1807 Reply

    Done

    DataHandler.php:1823 Reply

    Done

    DataHandler.php:1826 Reply

    Then the condition would also match, if tcaFieldConf['hashed'] is not set, since it would result in "!false -> true"

    DataHandler.php:1827 Reply

    Unsure about this. fe_users and be_users are TYPO3 internal tables and we should not allow to save plain text passwords (also for custom password fields) to those tables.

    Feature-97104-NewTCATypePassword.rst:29 Reply

    Done

    Feature-97104-NewTCATypePassword.rst:41 Reply

    Done

    DataHandlerTest.php:223 Reply

    Test was removed, because I also removed the "saltedPassword" eval in DataHandler. Since the change can be considered breaking, I re-added the "saltedPassword" eval to dataHandler and also re-added the test. However, I think we should deprecate the "saltedPassword" eval in DataHandler, since we now also have the logic to TCA type=password.
  22. core-ci voted on patch set 7 V -1 03/17/22, 19:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24967

  23. Torben Hansen uploaded patch set 8 03/18/22, 06:40

  24. core-ci voted on patch set 8 V +1 03/18/22, 06:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24985

  25. Torben Hansen uploaded patch set 9 03/19/22, 17:31

  26. core-ci voted on patch set 9 V -1 03/19/22, 17:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24999

  27. Torben Hansen uploaded patch set 10 03/20/22, 07:00

  28. core-ci voted on patch set 10 V -1 03/20/22, 07:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25003

  29. Torben Hansen uploaded patch set 11 03/20/22, 10:46

  30. core-ci voted on patch set 11 V +1 03/20/22, 10:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25005

  31. Torben Hansen commented on patch set 11 03/20/22, 11:02

    PasswordElement.php:87 Reply

    Done

    PasswordElement.php:154 Reply

    Done
  32. Oli Bartsch commented on patch set 11 03/21/22, 10:30

    PasswordElement.php:63

    password is not allowed and is added below anyways

    DataHandler.php:1826 Reply

    Sure, you are right, default has to be TRUE: "!(tcaFieldConf['hashed'] ?? true)"

    DataHandler.php:1827 Reply

    Oke, should we then document this?

    DataHandler.php:2811

    This is removed/migrated in the TcaMigration and will therefore never match.

    TcaMigration.php:818

    Has to be "saltedPassword".

    DataHandlerTest.php:223 Reply

    It's fine, "saltedPassword" is migrated in the TcaMigration and therefore no breaking change. Actually the current state does not work since the DataHandler part will never be called due to the TcaMigration. What I meant, the functionality, this test case checked, should still apply. Therefore we should change the test to call `checkValueForPassword()`.
  33. Oliver Hader commented on patch set 11 03/21/22, 14:12

    PasswordElement.php:84

    I know I'm late to this party... however, instead of continuing generating HTML in PHP, we might consider handling new elements (new TCA types) as custom-element instead. For instance we did that in v11 with the table wizard element, see * https://github.com/TYPO3/typo3/blob/929dcbf07cbfb906fd2f7e20b79f50aedd875762/typo3/sysext/backend/Classes/Form/Element/TextTableElement.php#L250 * https://github.com/TYPO3/typo3/blob/7a41f9052f89215220625c6d5e7a5ed21009667b/Build/Sources/TypeScript/backend/element/table-wizard-element.ts What do you think?
  34. Benni Mack commented on patch set 11 03/21/22, 15:46

    PasswordElement.php:84 Reply

    yeah, I think this makes sense to do this. but I think we should do this in a separate step (I guess there is more to it related to FormEngine JS)
  35. Torben Hansen uploaded patch set 12 03/24/22, 09:22

  1. Torben Hansen commented on patch set 12 03/24/22, 09:24

    PasswordElement.php:63 Reply

    Done

    DataHandler.php:1826 Reply

    Done

    DataHandler.php:1827 Reply

    Done

    DataHandler.php:2811 Reply

    Done

    TcaMigration.php:818 Reply

    Done

    DataHandlerTest.php:223 Reply

    I'm struggling a bit with how to implement this. `checkValueForPassword()` is declared protected, so we can not call this directly in the test. Should I try to mock dataHandler or should I try to call `checkValue_SW`?
  2. core-ci voted on patch set 12 V -1 03/24/22, 09:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25094

  3. Oli Bartsch uploaded patch set 13 03/25/22, 17:35

  4. Oli Bartsch commented on patch set 13 03/25/22, 17:35

    DataHandlerTest.php:223 Reply

    Done
  5. core-ci voted on patch set 13 V +1 03/25/22, 17:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25149

  6. Benni Mack commented on patch set 13 03/25/22, 18:19

    PasswordElement.php:84 Reply

    Done
  7. Benni Mack commented on patch set 13 03/25/22, 18:20

    fe_users.php:42

    I think we can remove "max" here

    fe_users.php:44

    should we have this as "default"?
  8. Torben Hansen uploaded patch set 14 03/25/22, 18:58

  9. Torben Hansen commented on patch set 14 03/25/22, 18:59

    fe_users.php:42 Reply

    Done. Also changed this in be_users

    fe_users.php:44 Reply

    Yes, now we have `autocomplete=off` as default and `autocomplete=new-fieldname` if the autocomplete config is set to `true` in TCA.
  10. Benni Mack commented on patch set 14 03/25/22, 19:00

    Feature-97104-NewTCATypePassword.rst:39

    I question this option ;)

    Feature-97104-NewTCATypePassword.rst:63

    should be "saltedPassword"
  11. Benni Mack commented on patch set 15 03/25/22, 19:02

    Published edit on patch set 14.
  12. core-ci voted on patch set 14 V +1 03/25/22, 19:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25150

  13. core-ci voted on patch set 15 V -1 03/25/22, 19:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25151

  14. core-ci voted on patch set 15 V +1 03/25/22, 20:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25151

  15. Oli Bartsch uploaded patch set 16 03/25/22, 23:08

  16. Oli Bartsch commented on patch set 16 03/25/22, 23:09

    Feature-97104-NewTCATypePassword.rst:39 Reply

    Done

    Feature-97104-NewTCATypePassword.rst:63 Reply

    Done
  17. core-ci voted on patch set 16 V +1 03/25/22, 23:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25166

  18. Oli Bartsch voted on patch set 16 V +1 CR +1 03/25/22, 23:19

  19. Oli Bartsch uploaded patch set 17 03/25/22, 23:58

  20. Benni Mack voted on patch set 17 V +1 CR +1 03/26/22, 00:02

  21. core-ci voted on patch set 17 V -1 03/26/22, 00:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25169

  22. core-ci voted on patch set 17 V +1 03/26/22, 00:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25169

  23. Oli Bartsch commented on patch set 17 V -1 CR +2 03/26/22, 00:18

    Will prepare styleguide adjustments.
  24. Oli Bartsch commented on patch set 17 V +2 03/26/22, 12:04

  25. Oli Bartsch merged patch set 18 03/26/22, 12:04