Review main Merged Breaking

52737[!!!][TASK] Implement Salted Passwords against SaltInterface

Christian Futterlieb CR +2 V +2 Hard +208 −150 updated 12/13/17, 11:44

Commit message

Salt classes must implement SaltInterface only. The AbstractSalt
class is renamed to AbstractComposedSalt and implements
SaltInterface. Methods for salt-classes that compose the
password-hash string themselves (which are currently all in
saltedpasswords) are moved to AbstractComposedSalt as well.

This cleanup change prepares for the integration of the
PHP password API in a following change.

Review

  • Code review CR +2
    • Benni Mack +2
    • Stefan Neufeind +1
    • Christian Kuhn +1
  • Verified V +2
    • Benni Mack +2
    • Christian Kuhn +1
    • TYPO3com +1 CI

Issues 1

Files 16

Review log 5267

Show 3142 earlier messages
  1. Christian Futterlieb uploaded patch set 1 05/08/17, 17:58

  2. TYPO3com voted on patch set 1 V +1 05/08/17, 18:04 Completed build in 05m 23s on Mon, 8 May, 08:04 PM Test Summary: 55788 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-11272

  3. Oliver Klee commented on patch set 1 05/08/17, 18:23

    AbstractComposedSalt.php:21

    Should it be "composed salt" or "compound salt"?

    SaltFactory.php:146

    Why not keep the interface here (and in the field)?

    SaltInterface.php:38

    I'd prefer to keep these two methods in the interface. The interface should define the interface, and the abstract class should fill the interface with shared code. Or am I missing something?

    ClassAliasMap.php:3

    Please let's have a comma after the last array element.

    SaltFactoryTest.php:86

    Please use assertInstanceOf for all these checks.
  4. Christian Futterlieb commented on patch set 1 05/08/17, 19:21

    AbstractComposedSalt.php:21 Reply

    It could have been "combined salt" as well :-) The name should just reflect, that child classes create password hashes like $identifier . $options . $salt . $hash This will contrast to the (future) implementation of AbstractPhpPasswordHashSalt

    SaltFactory.php:146 Reply

    Sry, I don't get what you mean

    SaltInterface.php:38 Reply

    The reasons why these method should go to the abstract class are: 1. They are both methods, that will only ever be used by salts, that compose the password hash themselves, as they provide internal information about a salt. In the upcoming change which adds the php password api, they just would not make sense 2. They are never called from anywhere in the core, nor from another piece of code inside saltedpasswords including AbstractComposedSalt! Technically, these methods could be left away completely.
  5. Oliver Klee commented on patch set 1 05/08/17, 19:21

    If you're touching the CR anymway: It should either be "Clean up the" (the verb) or "Clean up of the" (noun). Also: api -> API
  6. Oliver Klee commented on patch set 1 05/08/17, 20:13

    AbstractComposedSalt.php:21 Reply

    If I understand this correctly, it's not the salt that's combined of things, but the password hash. Do I understand this right? If so, we should change the name.

    SaltFactory.php:146 Reply

    Oh, I misread the code, and hence wrote nonsense. Please just disregard my comment. :-)

    SaltFactory.php:147

    Oh, and we can drop the is_object. makeInstance will always return an object.
  7. Christian Futterlieb uploaded patch set 2 05/08/17, 20:38

  8. TYPO3com voted on patch set 2 V +1 05/08/17, 20:43 Completed build in 05m 04s on Mon, 8 May, 10:43 PM Test Summary: 55788 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-11274

  9. Christian Futterlieb commented on patch set 1 05/08/17, 20:50

    Reply

    Done

    AbstractComposedSalt.php:21 Reply

    Correct. But in the case of EXT:saltedpasswords, things are a little messy. Probably for historical reasons. Sometimes a "salt" means the salt-portion of the hash and some(other)times it means the complete hash. For example the classes, that do the hashing, are called 'Salt's. I do not like this mess as well, but fixing the naming it will be a nightmare. Imo at some point it could be a good idea, to completely overwork/redesign authentication in TYPO3 and drop saltedpasswords. While this will be a huge change, I decided to go for smaller steps and just carry on with saltedpasswords as it is for now, to eventually get closer to modern password storage approaches.

    SaltFactory.php:147 Reply

    Done

    SaltFactoryTest.php:86 Reply

    Done
  10. Oliver Klee voted on patch set 2 CR +1 05/08/17, 23:00

  11. Oliver Klee updated the commit message in patch set 3 05/08/17, 23:09

  12. Oliver Klee voted on patch set 3 CR +1 05/08/17, 23:09

  13. TYPO3com voted on patch set 3 V +1 05/08/17, 23:15 Completed build in 05m 27s on Tue, 9 May, 01:15 AM Test Summary: 55788 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-11275

  14. Andreas Kienast updated the commit message in patch set 4 05/09/17, 06:30

  15. TYPO3com voted on patch set 4 V +1 05/09/17, 06:35 Completed build in 05m 29s on Tue, 9 May, 08:35 AM Test Summary: 55788 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-11276

  16. Oliver Klee commented on patch set 4 CR +1 V +1 05/09/17, 09:43

    Tested by running the tests.
  17. Oliver Klee commented on patch set 4 05/09/17, 09:46

    And BE login also still works fine.
  18. Philipp Gampe voted on patch set 4 CR +1 05/09/17, 11:36

  19. Elmar Hinz commented on patch set 4 CR +1 05/11/17, 18:13

    ClassAliasMap.php:4

    I put a question mark here, as the classes are not really the same.
  20. Christian Futterlieb commented on patch set 4 05/12/17, 08:03

    ClassAliasMap.php:4 Reply

    That's what Benni Mack asked me to do when renaming a class, because it is breaking (see https://review.typo3.org/51740). Besides that: you're right, they are - interface-wise - not exactly the same. But de facto every salting class has to implement the Interface and extend the abstract class by now, so it is at least convenient. Another question: what is the official strategy with such aliasMaps? When will it be removed? Shouldn't be at least a comment about that inside the code?
  21. Elmar Hinz commented on patch set 4 05/12/17, 08:13

    ClassAliasMap.php:4 Reply

    Good point. When are the maps to remove? Maybe bring up that question on slack. (With the disadvantage not to have an archive of the results of the discussion.)
  22. Frank Nägler commented on patch set 4 08/18/17, 14:22

    patch needs a rebase
  23. Stefan Neufeind uploaded patch set 5 12/07/17, 07:50

  24. Stefan Neufeind commented on patch set 5 12/07/17, 07:50

    hand-rebased because of composer.json
  25. Stefan Neufeind commented on patch set 5 12/07/17, 07:52

    first subtask of a three, according to https://review.typo3.org/51740
  26. TYPO3com voted on patch set 5 V -1 12/07/17, 08:01 Completed build in 11m 35s on Thu, 7 Dec, 09:01 AM Test Summary: 4 of 2806 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17281

  27. TYPO3com commented on patch set 5 12/07/17, 08:26 Completed build in 48m 10s on Thu, 7 Dec, 09:26 AM Test Summary: 4 of 2806 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17281

  28. Stefan Neufeind uploaded patch set 6 12/11/17, 07:55

  29. Stefan Neufeind commented on patch set 6 12/11/17, 07:56

    resolved merge-conflict (just because of composer.lock)
  30. Stefan Neufeind uploaded patch set 7 12/11/17, 07:59

  31. Stefan Neufeind commented on patch set 7 12/11/17, 08:01

    re-added missing ClassAliasMap.php from patchset 4 !!! Please note there was discussion about that file in patchset 4. Not sure if that needs further discussion.
  32. Stefan Neufeind uploaded patch set 8 12/11/17, 08:03

  33. TYPO3com voted on patch set 6 V -1 12/11/17, 08:07 Completed build in 11m 08s on Mon, 11 Dec, 09:07 AM Test Summary: 4 of 2812 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17550

  34. TYPO3com voted on patch set 7 V -1 12/11/17, 08:11 Completed build in 11m 43s on Mon, 11 Dec, 09:11 AM Test Summary: 4 of 2812 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17551

  35. TYPO3com voted on patch set 8 V -1 12/11/17, 08:13 Completed build in 10m 14s on Mon, 11 Dec, 09:13 AM Test Summary: 4 of 2812 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17552

  36. Stefan Neufeind uploaded patch set 9 12/11/17, 08:37

  37. Stefan Neufeind commented on patch set 9 12/11/17, 08:38

    AbstractComposedSalt was missing
  38. TYPO3com voted on patch set 9 V +1 12/11/17, 08:47 Completed build in 10m 24s on Mon, 11 Dec, 09:47 AM Test Summary: 57069 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17556

  39. Benni Mack commented on patch set 9 CR -1 12/11/17, 21:53

    RST is still missing
  40. Benni Mack uploaded patch set 10 12/12/17, 07:13

  41. TYPO3com voted on patch set 10 V -1 12/12/17, 07:20 Completed build in 07m 29s on Tue, 12 Dec, 08:20 AM Test Summary: 18 of 30137 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17613

  42. Benni Mack uploaded patch set 11 12/12/17, 07:25

  1. Georg Ringer commented on patch set 11 12/12/17, 07:31

    I really don't like the combination of "cleanup" and "breaking" in the commit title.
  2. TYPO3com voted on patch set 11 V -1 12/12/17, 07:37 Completed build in 12m 25s on Tue, 12 Dec, 08:37 AM Test Summary: 9 of 30137 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17615

  3. Benni Mack updated the commit message in patch set 12 12/12/17, 07:46

  4. TYPO3com voted on patch set 12 V -1 12/12/17, 07:58 Completed build in 11m 54s on Tue, 12 Dec, 08:58 AM Test Summary: 9 of 30137 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17619

  5. Christian Futterlieb commented on patch set 12 CR -1 12/12/17, 09:29

    I have some remarks on the type declarations. If you agree, I'll fix them.

    BlowfishSalt.php:275

    Check obsoleted by type hint

    BlowfishSalt.php:288

    Check obsoleted by type hint

    BlowfishSalt.php:301

    Check obsoleted by type hint

    Pbkdf2Salt.php:358

    Check obsoleted by type hint

    Pbkdf2Salt.php:371

    Check obsoleted by type hint

    Pbkdf2Salt.php:384

    Check obsoleted by type hint

    PhpassSalt.php:374

    Check obsoleted by type hint

    PhpassSalt.php:387

    Check obsoleted by type hint

    PhpassSalt.php:400

    Check obsoleted by type hint

    SaltFactory.php:87

    Better remove this type declaration, this method can return null as well, for example when $saltedHash contains an unsupported password hash. It could thus break any login process, if SaltedPasswordService is registered (which it is by default), see SaltedPasswordService::compareUident(). Even worse: login data could be leaked through a stack trace.

    SaltFactory.php:146

    Same here, method can return null as well.
  6. Oliver Klee commented on patch set 12 12/12/17, 10:13

    BlowfishSalt.php:288 Reply

    We probably then can use the null coalesce operator for things like this.

    SaltFactory.php:85

    @return SaltInterface|null (according to the review comment below)
  7. Christian Kuhn commented on patch set 12 CR -1 12/12/17, 13:36

    on it.
  8. Christian Kuhn uploaded patch set 13 12/12/17, 14:05

  9. Christian Kuhn commented on patch set 12 12/12/17, 14:05

    BlowfishSalt.php:275 Reply

    Done

    BlowfishSalt.php:288 Reply

    Done

    BlowfishSalt.php:301 Reply

    Done

    Pbkdf2Salt.php:358 Reply

    Done

    Pbkdf2Salt.php:371 Reply

    Done

    Pbkdf2Salt.php:384 Reply

    Done

    PhpassSalt.php:374 Reply

    Done

    PhpassSalt.php:387 Reply

    Done

    PhpassSalt.php:400 Reply

    Done

    SaltFactory.php:85 Reply

    Done

    SaltFactory.php:87 Reply

    Done

    SaltFactory.php:146 Reply

    Done
  10. Christian Kuhn commented on patch set 13 12/12/17, 14:07

    rebased and resolved comments. there are still two test failures and i'm not sure what to do there: getHashedPassword() may return null without the patch, and it is tested for this. this is now changed to :string return type. how to proceed?
  11. TYPO3com voted on patch set 13 V -1 12/12/17, 14:15 Completed build in 09m 56s on Tue, 12 Dec, 03:15 PM Test Summary: 6 of 30137 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17658

  12. Christian Futterlieb commented on patch set 13 12/12/17, 14:25

    > getHashedPassword() may return null without the patch, and > it is tested for this. this is now changed to :string return type. > how to proceed? The return type declaration of Md5Salt::getHashedPassword() is wrong, the interface defines no return type for this method. I don't know why there is no Error thrown as it should, because Md5Salt does not comply the interface..
  13. Benni Mack commented on patch set 13 12/12/17, 14:40

    let's remove this info from the Interface and make that compliant, no worries.
  14. Benni Mack uploaded patch set 14 12/12/17, 14:43

  15. Stefan Neufeind voted on patch set 14 CR +1 12/12/17, 14:51

  16. TYPO3com voted on patch set 14 V +1 12/12/17, 14:52 Completed build in 09m 22s on Tue, 12 Dec, 03:52 PM Test Summary: 29976 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-17668

  17. Christian Kuhn voted on patch set 14 V +1 CR +1 12/12/17, 14:58

  18. Benni Mack voted on patch set 14 V +2 CR +2 12/12/17, 14:59

  19. Benni Mack merged patch set 15 12/12/17, 14:59

  20. Nicole Hummel commented on patch set 15 12/12/17, 19:24

    Post -1 I would love to see the removed methods from the SaltInterface in a new ComposedSaltInterface that is impletented in the current salt classes. This seems to be much more cleaner than moving those function into an abstract class
  21. Benni Mack commented on patch set 15 12/12/17, 20:51

    agreed, something like that, Nicole? https://review.typo3.org/#/c/55060/
  22. Christian Futterlieb commented on patch set 15 12/13/17, 10:07

    > This seems to be much more cleaner than moving those > function into an abstract class It surely would be, if any code outside saltedpasswords (even outside the salt classes themselves) would care to consume the interface. Which is not the case and most probably will never be. The AbstractComposedSalt is (and was) more or less a ‘utility’ and/or ‘guidline' for concrete salt class implementations. The SaltInterface already defines all needed methods to meaningfully deal with a salt object. Thus introducing a new interface makes imho no sense at all. I know, the interface is merged already, consider my comment as ‘just for the record’ :)
  23. Nicole Hummel commented on patch set 15 12/13/17, 10:51

    @Christian: What was the sense moving the functions to an abstract class as abstract functions and renaming the abstract class then?
  24. Stefan Neufeind commented on patch set 15 12/13/17, 11:26

    I agree with Nicole/Benni that with the given classes this solution for another interface inbetween imho makes sense / is the clean solution. So thanks for bringing this up.
  25. Christian Futterlieb commented on patch set 15 12/13/17, 11:44

    > @Christian: What was the sense moving the functions to an abstract > class as abstract functions and renaming the abstract class then? Hi Nicole. It's intended for the purpose described in the commit msg: prepare for the integration of the PHP password API in a subsequent change. My thoughts are: 1. Rename the abstract class: clarify its purpose 2. Move the two functions: they should not belong to the SaltInterface as they’re used inside the current salt classes exclusively and thus belong only to those classes. Then with the ‘cleaned-up’ interface things get prepared for the integration of the PHP password API 3. My general opinion is that interfaces should be used only to define - well - interfaces for other code to consume and not for code-structuring purposes. When they are introduced they immediately become public API and will stay for a long time in TYPO3 (at least 2 major versions). So an abstract class did seem to fit better.