81317[BUGFIX] Keep session data written during login
Commit message
Test this change
Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch
- Check out patch set 6
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/17/81317/6 && git checkout FETCH_HEAD - Cherry-pick onto main
-
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/17/81317/6 && git cherry-pick FETCH_HEAD
Review
-
Code review CR +1 Needs a vote
- Markus Klein +1
-
Verified V 0 Needs a vote
- core-ci +1 CI
Merge conflicts 2
Issues 1
Files 4
- typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php1+1 −3
- typo3/sysext/core/Tests/Functional/Authentication/Fixtures/FixtureAuthenticationService.php+9 −0
- typo3/sysext/core/Tests/Functional/Authentication/AbstractUserAuthenticationTest.php+14 −0
- typo3/sysext/frontend/Tests/Functional/Authentication/FrontendUserAuthenticationTest.php+87 −35
Review log 2025
-
Xavier Perseguers uploaded patch set 1 10/04/23, 05:13
-
Xavier Perseguers updated the commit message in patch set 2 10/04/23, 05:19
-
core-ci voted on patch set 1 V +1 10/04/23, 05:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47379
-
core-ci voted on patch set 2 V +1 10/04/23, 05:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47381
-
Oliver Klee commented on patch set 2 10/04/23, 16:09
Can we cover this with a (regression) test? -
Garvin Hicking commented on patch set 2 10/04/23, 18:53
UserSession.php:206This should probably isUseData... which sounds a bit wonky? Maybe there's a better name for this property, also because the other file remaps it to "forcePreserveSessionData". Sadly I'm not versed in the MFA routines. Some rough ideas: (is)SessionDataPreserved (is)SessionDataOverrideWithImportedData (is)OverriddenSessionData (is)ExternalSessionData (is)ExistingSessionData (is)ImporterSessionData (is)InjectedSessionData ? -
Xavier Perseguers commented on patch set 2 10/05/23, 12:52
Reply
certainly but to be honest I'd need help or some guidance here.UserSession.php:206ReplyisUseData makes no sense, "useData" is already having a verb at the beginning... "use" so no need for another one with "is". However I'm totally fine to discuss a better name. But all your suggestions are imho a bit less optimal since it implies the class knows about the injection of something into itself, whereas my proposal is more a flag for the "outside" to tell that its data is worth being reused whenever the "outside" wants to recreate it. -
Oliver Klee commented on patch set 2 10/05/23, 13:21
Reply
I'll gladly help. I propose we meet up for a pair programming session. Can you please ping me on Slack so we can arrange something? -
Garvin Hicking commented on patch set 2 10/06/23, 07:35
UserSession.php:206ReplyA general convention is that boolean getters use "isXXX", that's what I was only trying to point at. The current naming scheme conflicts that, I do agree - which is why a better suited name would be great. :-) Sadly I'm not too deep into what actually is tried to be performed. Could you maybe describe that, that might yield some other variable names. Given what you wrote now, how about: (is)OutsideSessionData (is)UsingOutsideSessionData (is)SessionDataComingFromExternalSource (is)SessionDataComingFromOutside (is)SessionDataExternal ? -
Xavier Perseguers commented on patch set 2 10/06/23, 07:40
UserSession.php:206ReplyPlease have a look at what is written in the related ticket, that's the best explanation you can get and you'll have the whole overview. thanks. -
Garvin Hicking commented on patch set 2 10/06/23, 07:57
UserSession.php:206Reply UnresolvedMaybe Oliver has ideas about the naming when you write tests for it, I'll just leave it at this :-) -
Xavier Perseguers commented on patch set 2 10/13/23, 12:03
Frankly said, I tried to kickstart some functional test for that but the amount of work to check a dumb boolean flag set by some 3rd-party extension sounds totally insane. I will need this bugfix back into TYPO3 v11 and I doubt that even if it finds its way into the Core that someone would allow and work on backporting all that stuff into TYPO3 v11. I feel like it's not worth it as I may be the only one trying to make actual use of the `mfa` field from table `fe_users`. Thus I guess best for me to just stick relying on dedicated fields instead of trying to make real use of the native one and wait for someone else actually trying to implement a native handling of MFA into core stumble upon that very problem and work on it as part of adding the full MFA handling for Frontend into the Core. I don't feel like investing hours for writing tests if I can't benefit from it in TYPO3 v11 and I don't feel like making loose hours to other devs either trying to help me doing that. -
Garvin Hicking commented on patch set 2 10/13/23, 15:20
Reply
I feel sadness and frustration from you and was really impacted by it. I'd be really interested to learnctesting this. Let me try to find some time (not immediate, but hopefully "soonish") to get into this. I always wanted to understand the MFA authentication, and would love to learn from your work. Let's go for an optimistic outlook on this :-) -
Oliver Klee wrote 08/25/24, 10:12
Removed cc Oliver Klee. -
Benni Mack updated the commit message in patch set 3
V +110/18/24, 13:46 -
Benni Mack updated the commit message in patch set 4 04/22/26, 06:34
-
core-ci voted on patch set 4 V -1 04/22/26, 12:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100739
-
Benni Mack rebased onto patch set 5
V -110/02/26, 09:06 -
core-ci voted on patch set 5 V +1 10/02/26, 09:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109894
-
Wolfgang Klinger uploaded patch set 6
V +110/02/26, 10:56 -
Wolfgang Klinger commented on patch set 6 10/02/26, 10:58
Instead of adding a flag, the if ($anonymousSession || $isExistingSession) guard is removed. The guard is from the 2015 session framework, where the data was copied from the database row of the anonymous session and no row existed for a new session. Since the UserSession object in 2020 the data is taken from the in-memory object before fixation, so the guard only excluded the case this issue is about. Removing it has the same effect as the flag without new API. Services only need $this->pObj->getSession()->set('mfa', true). Regression tests included: one on the shared code path in AbstractUserAuthenticationTest, one for the reported frontend scenario in FrontendUserAuthenticationTest. hth -
core-ci voted on patch set 6 V +1 10/02/26, 11:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109917
-
Markus Klein voted on patch set 6 CR +1 10/12/26, 08:33
-
Benni Mack commented on patch set 6 11/16/26, 08:32
Reply
tests are added. -
Oli Bartsch commented on patch set 6 11/17/26, 15:08
AbstractUserAuthentication.php:562UnresolvedIn the backend the carried session data is only set on the in-memory `UserSession`, because `elevateToFixatedUserSession()` stores `ses_data` as `''`. The frontend saves it at the end of the request, the backend does not, so a second request loads no `mfa` and throws `MfaRequiredException`. Please persist it at fixation (write the collected data in `elevateToFixatedUserSession()`, or call `$this->userSessionManager->updateSession()` after `overrideData()` when the data is not empty, like `setAndSaveSessionData()` does). The backend test should then assert `mfa` after a second `start(buildSessionRequest(jwt))`, as it currently only checks the same object and passes anyway. Alternatively, limit the change and the commit message to the frontend and drop the backend test. Also note that `initializeBackendLogin()` skips `handleUserLoggedIn()` when `mfa` is in the session. With the guard gone, a backend auth service writing `mfa` makes the login skip `AfterUserLoggedInEvent`, and for a user without an active provider `MfaController` never runs. Login notification mails and the `password_reset_token` reset are then silently skipped. Please decouple "login already handled" from the `mfa` key (e.g. a dedicated session marker set by `MfaController`), or, if you scope this to the frontend, document that backend services must not set `mfa`.