jwt icon indicating copy to clipboard operation
jwt copied to clipboard

"message": "Class 'Mdanter\\Ecc\\EccFactory' not found",

Open michaelchemani opened this issue 9 years ago • 16 comments

Got "Class 'Mdanter\\Ecc\\EccFactory' not found"

when doing

` $signer = new \Lcobucci\JWT\Signer\Ecdsa\Sha256();

    $token = (new Builder())->setIssuer('http://example.com') // Configures the issuer (iss claim)
    ->setAudience('http://example.org') // Configures the audience (aud claim)
    ->setId('4f1g23a12aa', true) // Configures the id (jti claim), replicating as a header item
    ->setIssuedAt(time()) // Configures the time that the token was issue (iat claim)
    ->setExpiration(time() + 3600) // Configures the expiration time of the token (nbf claim)
    ->set('uid', 1) // Configures a new claim, called "uid"
    ->sign($signer,  $privateKey) // creates a signature using your private key
    ->getToken(); // Retrieves the generated token`

michaelchemani avatar May 19 '17 13:05 michaelchemani

@michaelchemani how was this installed? What are your dependencies? (check your composer.lock)

Ocramius avatar May 19 '17 14:05 Ocramius

@Ocramius , I got it to work. I was missing "mdanter/ecc": "^0.4.2" in my composer packages.

Now I got that :

"message": "Type error: Argument 1 passed to Lcobucci\\JWT\\Signer\\Ecdsa\\KeyParser::__construct() must be an instance of Mdanter\\Ecc\\Math\\MathAdapterInterface, instance of Mdanter\\Ecc\\Math\\GmpMath given, called in /vagrant/vendor/lcobucci/jwt/src/Signer/Ecdsa.php on line 50",

What did I do wrong?

michaelchemani avatar May 19 '17 15:05 michaelchemani

@michaelchemani consider providing a composer.json, a composer.lock and a file to reproduce this: we can't guess your dependencies ^_^

Ocramius avatar May 19 '17 15:05 Ocramius

My composer.json got "lcobucci/jwt": "^3.2" but it looks like Mdanter package isn't loaded.

michaelchemani avatar May 19 '17 16:05 michaelchemani

@michaelchemani if you look at packagist mdanter/ecc is not required as default it's just suggested (and installed for development so that we can run the tests).

The stable version of lcobucci/jwt is only compatible with mdanter/ecc: ~0.3.1 (that was already fixed on 4.0.x-dev and it's planned to be fixed on #137).

This means that if you want to use ECDSA you must do composer require mdanter/ecc:~0.3.1.

lcobucci avatar May 19 '17 22:05 lcobucci

@michaelchemani did this solve your problem?

lcobucci avatar Jun 20 '17 20:06 lcobucci

I'm going to close this issue as invalid since we didn't have any update.

lcobucci avatar Jul 30 '17 01:07 lcobucci

composer require mdanter/ecc:~0.3.1 solved it for me (using lcobucci/jwt:~3.2)

peterpostmann avatar Sep 13 '17 11:09 peterpostmann

@lcobucci Hi Luis! I'm using your JWT library with Ecdsa and thus had to do add mdanter/ecc:~0.3.1 to my composer.json.

Do you have an update on when version 3.2 of your library will be able to use later versions of mdanter/ecc? The 0.3.1 version of mdanter/ecc uses symfony/console ^2.6 but I would ideally like to make my app use symfony/console ^3.3. Also, I'd like my code to be compatible with PHP 5.6+.

Thanks!

ryanmats avatar Nov 02 '17 01:11 ryanmats

@ryanmats we are working on dropping that library completely and just use OpenSSL (and the extract the points "manually"). During tests, that shows a major improvement in performance when using ECDSA algorithms and removes the need for that dependency.

That will be available in v3.3 but we don't have a timeline at the moment. That version will require PHP 5.6+ and will be the last release of v3.x (with features, sure).

lcobucci avatar Nov 02 '17 07:11 lcobucci

@lcobucci thanks, i'll be on the lookout for that in the future.

ryanmats avatar Nov 02 '17 20:11 ryanmats

@lcobucci I ran into this problem today. It's now 5 months later. Is there a now timeframe when the new version will arrive?

B4rb4ross4 avatar Apr 16 '18 17:04 B4rb4ross4

Is there a now timeframe when the new version will arrive?

Whenever it's done :-)

Ocramius avatar Apr 16 '18 17:04 Ocramius

I think I'm going to fork this and use an updated ecdsa implementation

raininja avatar Jun 24 '18 04:06 raininja

Send PRs to finish up 4.x, rather?

Ocramius avatar Jun 24 '18 11:06 Ocramius

@raininja https://github.com/lcobucci/jwt/pull/247

lcobucci avatar Jun 24 '18 22:06 lcobucci