Skip to content

Commit

Permalink
Fixing exception when Passport keys are stored in env vars
Browse files Browse the repository at this point in the history
Passport keys can be stored in environment variables (https://laravel.com/docs/10.x/passport#loading-keys-from-the-environment)
but the service provider was expecting the key to exist in a file.

This commit fixes the issue by referencing the key directly from memory.
  • Loading branch information
moufmouf committed Jun 17, 2024
1 parent 0f704b3 commit c2f2a04
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion src/Grant/AuthCodeGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface;
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
use League\OAuth2\Server\RequestTypes\AuthorizationRequest;
use League\OAuth2\Server\ResponseTypes\RedirectResponse;
use OpenIDConnect\Interfaces\CurrentRequestServiceInterface;
use Psr\Http\Message\ResponseInterface;

Expand Down
1 change: 0 additions & 1 deletion src/IdTokenResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use DateInterval;
use DateTimeImmutable;
use Defuse\Crypto\Key;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Configuration;
use League\OAuth2\Server\CryptTrait;
Expand Down
1 change: 0 additions & 1 deletion src/Laravel/LaravelCurrentRequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class LaravelCurrentRequestService implements CurrentRequestServiceInterface
{

public function getRequest(): ServerRequestInterface
{
return (new PsrHttpFactory(
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/PassportServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function makeAuthorizationServer(): AuthorizationServer
app(ClaimExtractor::class),
Configuration::forSymmetricSigner(
app(config('openid.signer')),
InMemory::file($cryptKey->getKeyPath()),
InMemory::plainText($cryptKey->getKeyContents()),
),
app(LaravelCurrentRequestService::class),
$encryptionKey,
Expand Down

0 comments on commit c2f2a04

Please sign in to comment.