From 6846697ae4ccc6e7c705f1185eb12ed5b45cc120 Mon Sep 17 00:00:00 2001
From: pfleu <fleutotp@gmail.com>
Date: Wed, 25 Jan 2023 15:17:33 +0100
Subject: [PATCH] =?UTF-8?q?Fix=20chemin=20vers=20cl=C3=A9=20publique=20dan?=
 =?UTF-8?q?s=20m=C3=A9thode=20get=20jwks=20(obtention=20certificat=20json)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 config/packages/league_oauth2_server.yaml | 4 ++--
 src/Controller/IndexController.php        | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/config/packages/league_oauth2_server.yaml b/config/packages/league_oauth2_server.yaml
index 00f08ec..c629d67 100644
--- a/config/packages/league_oauth2_server.yaml
+++ b/config/packages/league_oauth2_server.yaml
@@ -3,7 +3,7 @@ league_oauth2_server:
 
         # Full path to the private key file.
         # How to generate a private key: https://oauth2.thephpleague.com/installation/#generating-public-and-private-keys
-        private_key: '%env(resolve:OAUTH_PRIVATE_KEY)%'
+        private_key: '%kernel.project_dir%%env(resolve:OAUTH_PRIVATE_KEY)%'
 
         # Passphrase of the private key, if any
         private_key_passphrase: '%env(OAUTH_PASSPHRASE)%'
@@ -49,7 +49,7 @@ league_oauth2_server:
 
         # Full path to the public key file
         # How to generate a public key: https://oauth2.thephpleague.com/installation/#generating-public-and-private-keys
-        public_key: '%env(resolve:OAUTH_PUBLIC_KEY)%'
+        public_key: '%kernel.project_dir%%env(resolve:OAUTH_PUBLIC_KEY)%'
 
     scopes:
         # Scopes that you wish to utilize in your application.
diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php
index c3d9541..2f8165f 100644
--- a/src/Controller/IndexController.php
+++ b/src/Controller/IndexController.php
@@ -44,7 +44,7 @@ class IndexController extends AbstractController
     {
         // Load the public key from the filesystem and use OpenSSL to parse it.
         $kernelDirectory = $this->getParameter('kernel.project_dir');
-        $publicKey = openssl_pkey_get_public(file_get_contents($kernelDirectory . '/var/keys/public.key'));
+        $publicKey = openssl_pkey_get_public(file_get_contents($kernelDirectory . $_ENV['OAUTH_PUBLIC_KEY']));
         $details = openssl_pkey_get_details($publicKey);
         $jwks = [
             'keys' => [
-- 
GitLab