Class 'JWT' not found in /var/www/html...
Hi Folks,
I am using drupal 7 with php version 5.5.35.
We installed the openid module and there we have a class called OpenIDConnectClientBase.class.php. Inside this class, I am trying to define a method to decode the access code with this library but we are receiving the error: Class 'JWT' not found in /var/www/html/portal/sites/all/modules/openid_connect/includes/OpenIDConnectClientBase.class.php on line 204
What should be wrong?
1 - I installed your guys with composer require as asked.
2 - The code on OpenIDConnectClientBase.class.php is:
3 - Here are my folders: [user@myserver includes]# find . . ./OpenIDConnectClientBase.class.php ./OpenIDConnectClientInterface.class.php ./openid_connect.admin.inc ./openid_connect.forms.inc ./openid_connect.pages.inc ./composer.json ./vendor ./vendor/composer ./vendor/composer/installed.json ./vendor/composer/autoload_namespaces.php ./vendor/composer/autoload_psr4.php ./vendor/composer/autoload_classmap.php ./vendor/composer/autoload_static.php ./vendor/composer/autoload_real.php ./vendor/composer/ClassLoader.php ./vendor/composer/LICENSE ./vendor/composer/.autoload_real.php.swp ./vendor/autoload.php ./vendor/bin ./vendor/firebase ./vendor/firebase/php-jwt ./vendor/firebase/php-jwt/LICENSE ./vendor/firebase/php-jwt/README.md ./vendor/firebase/php-jwt/composer.json ./vendor/firebase/php-jwt/src ./vendor/firebase/php-jwt/src/BeforeValidException.php ./vendor/firebase/php-jwt/src/ExpiredException.php ./vendor/firebase/php-jwt/src/JWT.php ./vendor/firebase/php-jwt/src/SignatureInvalidException.php ./composer.lock
The code is:
<?php
require __DIR__ . '/vendor/autoload.php';
public function decodeJWTToken($jwt_token) {
$partes_token = explode('.', $jwt_token);
$key = 'mykey-test';
$decoded = JWT::decode( $jwt_token, $key, array('RS256'));
file_put_contents('php://stderr', print_r($decoded, TRUE));
return array();
}
?>
The code is trying to access the classJWT, which was namespaced to Firebase\JWT\JWT in v3.0.
You need to either update the code to use v5.0, or install v2.2 instead, as that's the last major release that does not use namespaces:
composer require firebase/php-jwt:^2.2
Updating the code is highly recommended, as security fixes have taken place since v2.2! This will take more effort and may require PRs to the openid connect module, but it'll be worth it!
For the record, I looked at the code in openid_connect module and at this github repository and couldn't find any reference to firebase JWT, so I'm really not sure what's going on here.
Hi bshaffer,
I am using the openid_connect_module in order to saveuser info with the roles that come in the token but for that, I need to decode the token. It is a base64 but we should use realm's key in order to guarantee the integrity.
That is reason why I am trying to use the Firebase JWT.
I understood that I can install 2.2 but how can I handle it if I want to use the 5.0 version?