Review main Merged

67032[FEATURE] Only set cookies for HTTP Responses in PSR-15 middlewares

Benni Mack CR +2 V +2 Normal +110 −30 updated 12/08/20, 07:40

Commit message

In previous TYPO3 versions, AbstractUserAuthentication emitted
cookies directly via header() or setcookie() methods.

In order to have a better testing scenario, this change
builds Cookie objects and keeps them until a PSR-15 middleware
asks to apply the cookie information to a PSR-7 Response.

This also makes it possible to manipulate the authentication
cookies in Middlewares.

AbstractUserAuthentication does not actually "remove"
or "set" a cookie but rather keeps the information for
setting a cookie.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Oli Bartsch +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Oli Bartsch +1
    • TYPO3com +1 CI

Issues 1

Files 5

Review log 1625

  1. Benni Mack uploaded patch set 1 12/06/20, 12:12

  2. TYPO3com voted on patch set 1 V -1 12/06/20, 12:21 Completed build in 09m 03s on Sun, 6 Dec, 12:21 PM Test Summary: 5 of 32654 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7849

  3. Benni Mack uploaded patch set 2 12/06/20, 15:49

  4. TYPO3com voted on patch set 2 V -1 12/06/20, 15:49 Completed build in 23s on Sun, 6 Dec, 03:49 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7865

  5. Benni Mack uploaded patch set 3 12/07/20, 07:35

  6. TYPO3com voted on patch set 3 V -1 12/07/20, 07:35 Completed build in 18s on Mon, 7 Dec, 07:35 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7883

  7. TYPO3com commented on patch set 3 12/07/20, 08:09 Completed build in 33m 56s on Mon, 7 Dec, 08:09 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7883

  8. Benni Mack uploaded patch set 4 12/07/20, 09:55

  9. TYPO3com voted on patch set 4 V -1 12/07/20, 10:05 Completed build in 09m 28s on Mon, 7 Dec, 10:05 AM Test Summary: 32413 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7895

  10. Benni Mack uploaded patch set 5 12/07/20, 10:09

  11. Benjamin Franzke commented on patch set 5 12/07/20, 10:17

    BackendUserAuthenticator.php:87

    As already discussed via slack: Applying this on top of https://review.typo3.org/c/Packages/TYPO3.CMS/+/67042 would allow to post process $handle->handle withing catch ImmediateResponseException, as that'd be done by Middleware\ResponsePropagation.
  12. TYPO3com voted on patch set 5 V -1 12/07/20, 10:20 Completed build in 11m 06s on Mon, 7 Dec, 10:20 AM Test Summary: 32413 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7896

  13. Markus Klein commented on patch set 5 12/07/20, 10:25

    AbstractUserAuthentication.php:974

    really the name?
  14. Benni Mack rebased onto patch set 6 12/07/20, 14:35

  15. Benni Mack uploaded patch set 7 12/07/20, 14:35

  16. TYPO3com voted on patch set 6 V -1 12/07/20, 15:00 Completed build in 18m 32s on Mon, 7 Dec, 03:00 PM Test Summary: 32411 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7914

  17. TYPO3com voted on patch set 7 V -1 12/07/20, 15:00 Completed build in 18m 46s on Mon, 7 Dec, 03:00 PM Test Summary: 32411 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7915

  18. Oli Bartsch uploaded patch set 8 12/07/20, 15:24

  19. TYPO3com voted on patch set 8 V +1 12/07/20, 15:33 Completed build in 09m 20s on Mon, 7 Dec, 03:33 PM Test Summary: 32411 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7922

  20. Benni Mack commented on patch set 8 12/07/20, 15:40

    @bnf I suggest we get this in and then change the code as soon as we have solution for your generic Exception solution, OK?
  21. Oli Bartsch voted on patch set 8 V +1 CR +1 12/07/20, 16:43

  22. Benjamin Franzke commented on patch set 8 CR +1 12/07/20, 20:04

    Reply

    Yes, fine with me. In theory I would prefer to get this one in first: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67048 I think it's a bit difficult to review this patch with the inverted method name. On the other hand: That method existed with than name since 9.5, so it can wait for another patch as well.

    BackendUserAuthenticator.php:82

    Hm.. From what I see ImmediateResponseException will never be thrown from backendCheckLogin(). Yes, theoretically it's thrown there, but as login-state is already checked in line 75 using $this->context->getAspect('backend.user')->isLoggedIn(), this exception should never happen here. Now, that means the catch block is actually intended for those exceptions, that're possibly thrown in "inner" middlewares or controllers, right? Or can you actually trigger backendCheckLogin() to trigger this exception, with the aspect login check before? I'm asking because I'd like to refactor this to use response propagation exceptions (where Immediate responses are passed through the middleware stack) at some point and then this catch block would then only be left with backendCheckLogin() + createFromUserPreferences() which actually don't throw. On the other hand: The issue really is that we double check login-state here, that needs to be refactored anyway, so this can probably go in as is.
  23. Benjamin Franzke voted on patch set 8 V +2 CR +2 12/08/20, 07:39

  24. Benjamin Franzke commented on patch set 8 12/08/20, 07:40

    BackendUserAuthenticator.php:87 Reply

    will be done afterwards.

    AbstractUserAuthentication.php:974 Reply

    Done
  25. Benjamin Franzke merged patch set 9 12/08/20, 07:40