From 6e1ab2edd4fd8d518941de86e85e7413508410bb Mon Sep 17 00:00:00 2001 From: Andrew Broberg Date: Tue, 26 Mar 2024 16:59:25 +1100 Subject: [PATCH] feat: Add support for caching of verify certificates --- composer.json | 4 +++- src/OpenIdVerificatorConcrete.php | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index eb347d0..afb8a87 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,9 @@ "google/cloud-scheduler": "^1.6", "phpseclib/phpseclib": "^3.0", "google/auth": "^v1.29.1", - "laravel/framework": "^10.0|^11.0" + "laravel/framework": "^10.0|^11.0", + "php": "^8.1", + "symfony/cache": "^6.4" }, "require-dev": { "mockery/mockery": "^1.5", diff --git a/src/OpenIdVerificatorConcrete.php b/src/OpenIdVerificatorConcrete.php index bf78c80..9cc7b19 100644 --- a/src/OpenIdVerificatorConcrete.php +++ b/src/OpenIdVerificatorConcrete.php @@ -7,13 +7,20 @@ class OpenIdVerificatorConcrete extends Facade { + private AccessToken $accessToken; + + public function __construct(AccessToken $accessToken) + { + $this->accessToken = $accessToken; + } + public function verify(?string $token, array $config): void { if (! $token) { throw new CloudSchedulerException('Missing [Authorization] header'); } - $payload = (new AccessToken())->verify( + $payload = $this->accessToken->verify( $token, [ 'audience' => config('cloud-scheduler.app_url'),