#100704FrontEnd MfaProviderPropertyManager storeProperties fails if no logger available
Description
I’m using the Typo3 providers for TOTP in frontend.
MfaProviderPropertyManager function storeProperties fails in frontend without logger. Data is stored!
protected function storeProperties(): bool
{
// encode the mfa properties to store them in the database and the user array
$mfa = json_encode($this->mfa, JSON_THROW_ON_ERROR) ?: '';
// Write back the updated mfa properties to the user array
$this->user->user[self::DATABASE_FIELD_NAME] = $mfa;
// Log MFA update
$this->logger->debug('MFA properties updated', [
'provider' => $this->providerIdentifier,
'user' => [
'uid' => $this->user->user[$this->user->userid_column],
'username' => $this->user->user[$this->user->username_column],
],
]);
// Store updated mfa properties in the database
return (bool)GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($this->user->user_table)->update(
$this->user->user_table,
[self::DATABASE_FIELD_NAME => $mfa],
[$this->user->userid_column => (int)$this->user->user[$this->user->userid_column]],
[self::DATABASE_FIELD_NAME => Connection::PARAM_LOB]
);
}
Failure near //Log MFA update
Both typo3 11 and 12
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 7
-
Frank Buijze commented 04/21/23, 12:26
-
Garvin Hicking commented and changed category status
NewNeeds Feedback 07/31/24, 13:41Do you maybe still have the stacktrace available? Which error happens exactly?
The $this->logger object should always be available actually, the core utilizes it at many places, and there’s a something like a “NullLogger” that should be available.
-
Frank Buijze commented 07/31/24, 13:49
@ghi
The $this->logger is not initiated.
Resulting in an error that debug is called on an instance of null.
My workaround for now is to remove the logger line, but I need to do that after every update op typo3.
-
Markus Klein commented 08/01/24, 14:27
How do you use this in Frontend?
Core does not provide this for FE by default.
I suspect that your code using this in FE makes some mistake during initialization of the class. -
Georg Ringer commented and changed status
Needs FeedbackClosed 08/01/24, 14:31hey. I am closing the issue for the same reason as markus has provided.
however the issue #97838 and #102081 deal with MFA in frontend
-
Frank Buijze commented 08/01/24, 14:47
GeorgRingerMarkusKLeinThe problem occurs when a user activates mfa.
$provider = new \TYPO3\CMS\Core\Authentication\Mfa\Provider\TotpProvider($context); $fe = $this->request->getAttribute('frontend.user'); $mfapm = new \TYPO3\CMS\Core\Authentication\Mfa\MfaProviderPropertyManager($fe,'totp'); $bActivated = $provider->activate($this->request,$mfapm);The activate function triggers the internal storage function. After activation the mfa session variable is set or unset depending on the result.
This works as long as the logger line is removed.
The bug is one year old and maybe another update has solved the issue, by calling different functions. Documentation is limited.
-
Markus Klein commented 08/02/24, 17:21
Your problem is that you are not using correct API to retrieve services.
When usingnewfor theMfaProviderPropertyManagerthe logger is not initialized as this is done by the Container.Change this to:
$mfapm = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Authentication\Mfa\MfaProviderPropertyManager::class, $fe,'totp');and you should be good to go.
Data is not stored, but exception is thrown that debug is called on null.