Update code to work with stricter JWT library checks

This commit is contained in:
Jonny Barnes 2022-08-23 20:50:19 +01:00
parent 6e6b853112
commit 903ebf56eb
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
2 changed files with 6 additions and 3 deletions

View file

@ -85,7 +85,7 @@ class AppServiceProvider extends ServiceProvider
// Configure JWT builder
$this->app->bind('Lcobucci\JWT\Configuration', function () {
$key = InMemory::plainText('testing');
$key = InMemory::plainText(config('app.key'));
$config = Configuration::forSymmetricSigner(new Sha256(), $key);

View file

@ -37,7 +37,10 @@ class TokenServiceTest extends TestCase
$this->assertSame($data, $validData);
}
/** @test */
/**
* @test
* @throws \Exception
*/
public function tokensWithDifferentSigningKeyThrowsException(): void
{
$this->expectException(RequiredConstraintsViolated::class);
@ -56,7 +59,7 @@ class TokenServiceTest extends TestCase
->withClaim('me', $data['me'])
->withClaim('scope', $data['scope'])
->withClaim('nonce', bin2hex(random_bytes(8)))
->getToken($config->signer(), InMemory::plainText('r4andomk3y'))
->getToken($config->signer(), InMemory::plainText(random_bytes(32)))
->toString();
$service = new TokenService();