Review main Abandoned

78008[WIP][FEATURE] Provide PSR-7 request globally in user authentication

Torben Hansen CR 0 V 0 Easy +13 −0 updated 03/03/23, 10:12

Commit message

This patch introduces the new property `request` in
`AbstractUserAuthentication` which is set when authentication
is initialized. The getter can be used by authentication services
implementing `AuthenticationService` to retreive data from the
PSR-7 request.

@todo
- tests
- feature rst with example code

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 1

Review log 910

  1. Torben Hansen uploaded patch set 1 03/02/23, 18:44

  2. core-ci voted on patch set 1 V +1 03/02/23, 18:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38323

  3. Alexander Schnitzler commented on patch set 1 03/03/23, 09:17

    AbstractUserAuthentication.php:1310

    What is the purpose of this public getter? Why introduce it in this patch if you need the request only inside this class and its children?
  4. Torben Hansen commented on patch set 1 03/03/23, 09:27

    AbstractUserAuthentication.php:1310 Reply

    The current problem is, that `$GLOBALS['TYPO3_REQUEST']` (which should not be used by extension authors anyway) is not initialized at this point of the authentication process. So 3rd party authentication services have no possiblity to access the PSR-7 request in any way and need to retrieve all data manually. If e.g. site config is required by an authentication service, it must manually be fetched in the 3rd party authentication service (really a pain, if you do not have a request object, since `SiteMatcher` also requires a PSR-7 request). Having the PSR-7 request available through the getter, allows 3rd party authentication services to access the PSR-7 request using `$this->pObj->getRequest()`
  5. Christian Kuhn commented on patch set 1 CR -2 03/03/23, 09:52

    AbstractUserAuthentication.php:1310 Reply

    imho not a good idea. this allows fetching request from a global state de facto singleton instance throughout the system, especially when public. also, since user auth is a middleware thing, the request will probably change further, so this object is potentially an old instance.
  6. Christian Kuhn voted on patch set 1 CR -1 03/03/23, 09:53

  7. Benni Mack commented on patch set 1 CR -1 03/03/23, 09:53

    As I've been working in this area quite a lot, I recommend just adding it to authInfo array or something the like, so it ain't too "public" for everyone (think of $GLOBALS[BE_USER]->getRequest() - I wouldn't want that :)).
  8. Christian Kuhn commented on patch set 1 03/03/23, 09:56

    AbstractUserAuthentication.php:1310 Reply Unresolved

    the issue with the auth services has to me modeled differently somehow .. probobly by actively handing around the request, not by allowing it to be get'ed from "pObj" Since the auth service api sucks so hard, it may need adaptions before to deal with this properly.
  9. Torben Hansen commented on patch set 1 03/03/23, 10:12

    Reply

    Ah, did`nt have the `$GLOBALS[BE_USER]->getRequest()` in mind - yes, thats not good :-)
  10. Torben Hansen abandoned the change 03/03/23, 10:12

    No good idea