Skip to content

JWKS is broken with firebase/php-jwt >= 6.0 #530

Closed
@cnizzardini

Description

@cnizzardini

When a user installs firebase via composer req firebase/php-jwt they will get 6.0 or higher. This is not compatible with JwtAuthenticator when using JWKS.

1) Authentication\Test\TestCase\Authenticator\JwtAuthenticatorTest::testGetPayloadRS256
TypeError: Key material must be a string, resource, or OpenSSLAsymmetricKey

Reproduce:

  1. In this project simply run composer req --dev firebase/php-jwt:^6.0
  2. Run composer test

Problem lies here: https://github.com/cakephp/authentication/blob/2.x/src/Authenticator/JwtAuthenticator.php#L181

Solution is simply this:

$keyMaterial = new Key($keyMaterial->getMaterial(), $keyAlgorithms[$k]);

But that is not compatible with ^5.5

Something like this works but IDK how to test this or if its a good practice...

                if ($keyMaterial instanceof Key) {
                    $keyMaterial = new Key($keyMaterial->getKeyMaterial(), $keyAlgorithms[$k]);
                } else {
                    $keyMaterial = new Key($keyMaterial, $keyAlgorithms[$k]);
                }

I guess at the least documentation can get updated, but that is easy to miss...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions