typo3extbasetypo3-8.7.x

Authenticatee FrontendUser via PHP API call from Extbase


First of all im Using TYPO3 Version 8.7.

The current problem i'm facing regards authentication of FrontendUser (fe_user) stored on a given page (in this case pid 168).

Apparently i'm trying to authenticate user with given credentials sent by a mobile application. I'm able to parse the user data and perform an authentication:

// plain-text password
$password = 'XXX';
// salted user password hash
$saltedPassword = 'YYY';
// keeps status if plain-text password matches given salted user password hash
$success = FALSE;

if (\TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled('FE')) {
        $objSalt = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance($saltedPassword);
        if (is_object($objSalt)) {
                $success = $objSalt->checkPassword($password, $saltedPassword);
        }
}

While debugging this code snippet, i recognized the password sent by the user via Request, which gets encrypted with the given Salt algorithm change every time i retry this request. I'm not sure how to get a correct authentication, if the password changes constantly.

The $objSalt object contains the right Hashing Method($pbkdf2-sha256$25000), the password stored in the Database starts with the same prefix, but the actual payload is different.

So What is the exact problem or whats the thing i'm missing in the above code to complete the authentication?

Thanks for your help

BR,

Martin


Solution

  • the password sent by the user via Request, which gets encrypted with the given Salt algorithm change every time i retry this request

    Yes, that because the salt is changed every time.

    You should retrieve the salting instance with:

    $instance = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance($user['password']);