Skip to content

Add ES384 support #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2021
Merged

Add ES384 support #324

merged 4 commits into from
May 19, 2021

Conversation

sdrsdr
Copy link

@sdrsdr sdrsdr commented Mar 29, 2021

Taste case plus I've verified to be correctly working against ES384 token from NodeJS system

@google-cla
Copy link

google-cla bot commented Mar 29, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Mar 29, 2021
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@sdrsdr
Copy link
Author

sdrsdr commented Mar 29, 2021

@googlebot I signed it!

@google-cla
Copy link

google-cla bot commented Mar 29, 2021

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: yes and removed cla: no labels Mar 29, 2021
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

1 similar comment
@google-cla
Copy link

google-cla bot commented Mar 29, 2021

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@BramRoets
Copy link

@googlebot Is this blocked by anyhing? What can we do to get this merged? Thanks!

@sdrsdr
Copy link
Author

sdrsdr commented May 16, 2021

I guess we need a review but this repo is quite dead IMHO

@BramRoets
Copy link

That's too bad .. I think it's the most used PHP JWT library at the moment...

@bshaffer
Copy link
Collaborator

bshaffer commented May 17, 2021

@BramRoets @sdrsdr it's not dead yet!!

Sorry for the late reply, I missed this PR. This is a fantastic addition, I'll review / merge today!


// Verify decoding succeeds
$publicKey = file_get_contents(__DIR__ . '/ecdsa384-public.pem');
$decoded = JWT::decode($encoded, $publicKey, array('ES384'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I switch both occurences of ES384 above to ES256, and likewise if I switch ES256 to ES384 in the test function testEncodeAndDecodeEcdsaToken, the tests still pass. Can we use test-cases which are not interchangeable?

Also, since these two tests are so similar, it would be better to use a data provider:

    /**
     * @runInSeparateProcess
     * @dataProvider provideEncodeAndDecodeToken
     */
    public function testEncodeAndDecodeToken($privateKeyFile, $publicKeyFile, $alg)
    {
        $privateKey = file_get_contents($privateKey);
        $payload = array('foo' => 'bar');
        $encoded = JWT::encode($payload, $privateKeyFile, $alg);

        // Verify decoding succeeds
        $publicKey = file_get_contents($publicKeyFile);
        $decoded = JWT::decode($encoded, $publicKey, array($alg));

        $this->assertEquals('bar', $decoded->foo);
    }

    public function provideEncodeAndDecodeToken()
    {
        return [
            [__DIR__ . '/ecdsa-private.pem', __DIR__ . '/ecdsa-public.pem', 'ES256'],
            [__DIR__ . '/ecdsa384-private.pem', __DIR__ . '/ecdsa384-public.pem', 'ES384'],
        ];
    }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ES384 and ES256 are meant to be interchangeable the test should and will fail if you try to have only one place changed. I'm not really familiar with PHP code testing. PHP is not in my daily workset, I've long ago removed the setup on my pc needed for testing php code. Can you please merge it as is and then fix it to you liking?

Copy link
Collaborator

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will submit test refactor in another PR

@bshaffer bshaffer merged commit 9af3b99 into firebase:master May 19, 2021
@BramRoets
Copy link

@bshaffer Could you make a release including these changes? is there anything we can do to help this process?

Many thanks!

@bshaffer
Copy link
Collaborator

@BramRoets tagged in v5.3.0

@BramRoets
Copy link

Wow that was quick! Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants