pmill / aws-cognito

A PHP library for AWS Cognito user pools
MIT License
74 stars 62 forks source link

Exception: Attempted to call function "gmp_init" from namespace "Jose\Component\Core\Util". #8

Closed engharb closed 6 years ago

engharb commented 6 years ago

Hello, after updating the composer, and by calling verifyAccessToken I got the following error:

Attempted to call function "gmp_init" from namespace "Jose\Component\Core\Util".

CRITICAL14:01:47 | php | Call to undefined function Jose\Component\Core\Util\gmp_init()
-- | -- | --
CRITICAL14:01:47 | request | Uncaught PHP Exception Symfony\Component\Debug\Exception\UndefinedFunctionException: "Attempted to call function "gmp_init" from namespace "Jose\Component\Core\Util"." at /home/vagrant/myProject/vendor/web-token/jwt-core/Util/BigInteger.php line 54

do you know why is such error comes?

regards,

engharb commented 6 years ago

current api v = 0.2.3, the same error with 0.2.1

engharb commented 6 years ago

exception when calling verifyWithKeySet().

//class CognitoClient
public function decodeAccessToken($accessToken)
    {
        $algorithmManager = AlgorithmManager::create([
            new RS256(),
        ]);

        $serializerManager = new CompactSerializer(new StandardConverter());

        $jws = $serializerManager->unserialize($accessToken);
        $jwsVerifier = new JWSVerifier(
            $algorithmManager
        );

        $keySet = $this->getJwtWebKeys();
        if (!$jwsVerifier->verifyWithKeySet($jws, $keySet, 0)) {
            throw new TokenVerificationException('could not verify token');
        }

        return json_decode($jws->getPayload(), true);
    }

?

pmill commented 6 years ago

Looks like the new jwt library requires the gmp extension.

engharb commented 6 years ago

I have installed that via command: $ sudo apt-get install php7.2-gmp

pmill commented 6 years ago

Try a phpinfo() and see if the extension is listed

engharb commented 6 years ago

I fix that, I was to set the correct php version in nginx config file.

engharb commented 6 years ago

thank you a lot