Skip to content

Commit

Permalink
bug lexik#1015 Fix ECDSA algo names in LcobucciJWSProvider (lovenunu)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.x branch.

Discussion
----------

Fix ECDSA algo names in LcobucciJWSProvider

Hi,

While trying to use ECDSA signature, I encountered `The algorithm "ES256" is not supported by Lexik\Bundle\JWTAuthenticationBundle\Services\JWSProvider\LcobucciJWSProvider`.

This name mismatch is pretty clear observing the `GenerateKeyPairCommand` command, which defines `ES256`, `ES384` and `ES512`  in its `ACCEPTED_ALGORITHMS` constant.

This PR fixes this issue and allows usage of ESxxx algorithms.

Commits
-------

0bc858d Fix ECDSA algo names in LcobucciJWSProvider
  • Loading branch information
chalasr committed Apr 26, 2022
2 parents 3a26516 + 0bc858d commit 5ef8b77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Services/JWSProvider/LcobucciJWSProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ private function getSignerForAlgorithm($signatureAlgorithm)
'RS256' => Signer\Rsa\Sha256::class,
'RS384' => Signer\Rsa\Sha384::class,
'RS512' => Signer\Rsa\Sha512::class,
'EC256' => Signer\Ecdsa\Sha256::class,
'EC384' => Signer\Ecdsa\Sha384::class,
'EC512' => Signer\Ecdsa\Sha512::class,
'ES256' => Signer\Ecdsa\Sha256::class,
'ES384' => Signer\Ecdsa\Sha384::class,
'ES512' => Signer\Ecdsa\Sha512::class,
];

if (!isset($signerMap[$signatureAlgorithm])) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/Services/JWSProvider/LcobucciJWSProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function testCreateWithEcdsa()
->willReturn('foobar');

$payload = ['username' => 'chalasr'];
$jwsProvider = new LcobucciJWSProvider($keyLoaderMock, 'openssl', 'EC512', 3600, 0);
$jwsProvider = new LcobucciJWSProvider($keyLoaderMock, 'openssl', 'ES512', 3600, 0);

$this->assertInstanceOf(CreatedJWS::class, $created = $jwsProvider->create($payload));

Expand Down

0 comments on commit 5ef8b77

Please sign in to comment.