From 6a316aada74c8db5a98a891c003a4dc3bdbdec0e Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Thu, 3 Sep 2026 12:51:35 +0530 Subject: [PATCH] Name the signing key apart from the provider key Both base actions already bind $key to the provider and use it for the callback URL and the installation lookup, so reusing the name for the OpenSSL key sent every Gitea, GitLab and Bitbucket callback looking for a provider named after the key. --- src/Appwrite/Platform/Modules/VCS/Http/Authorize/Base.php | 6 +++--- src/Appwrite/Platform/Modules/VCS/Http/Callback/Base.php | 6 +++--- .../Platform/Modules/VCS/Http/GitHub/Authorize/Get.php | 6 +++--- .../Platform/Modules/VCS/Http/GitHub/Callback/Get.php | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Authorize/Base.php b/src/Appwrite/Platform/Modules/VCS/Http/Authorize/Base.php index b46898db9d..b99867477e 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Authorize/Base.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Authorize/Base.php @@ -97,9 +97,9 @@ abstract class Base extends Action $hostname = $platform['consoleHostname'] ?? ''; $callback = $protocol . '://' . $hostname . '/v1/vcs/' . $key . '/callback'; - $key = System::getEnv('_APP_OPENSSL_KEY_V1', ''); + $signingKey = System::getEnv('_APP_OPENSSL_KEY_V1', ''); - if (empty($key)) { + if (empty($signingKey)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Signing key is not configured. Please configure _APP_OPENSSL_KEY_V1 in .env file.'); } @@ -109,7 +109,7 @@ abstract class Base extends Action 'projectId' => $project->getId(), 'success' => $success, 'failure' => $failure, - 'signature' => \hash_hmac('sha256', \json_encode([$project->getId(), $success, $failure]), $key), + 'signature' => \hash_hmac('sha256', \json_encode([$project->getId(), $success, $failure]), $signingKey), ]; if (\strlen((string) \json_encode($state)) > APP_LIMIT_VCS_STATE) { diff --git a/src/Appwrite/Platform/Modules/VCS/Http/Callback/Base.php b/src/Appwrite/Platform/Modules/VCS/Http/Callback/Base.php index 88647da603..55f9ee1d2f 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/Callback/Base.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/Callback/Base.php @@ -83,13 +83,13 @@ abstract class Base extends Action // Authorize action put in state, anyone with their own valid // authorization code could pass an arbitrary projectId here and // attach their VCS account as an installation on another project. - $key = System::getEnv('_APP_OPENSSL_KEY_V1', ''); + $signingKey = System::getEnv('_APP_OPENSSL_KEY_V1', ''); - if (empty($key)) { + if (empty($signingKey)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Signing key is not configured. Please configure _APP_OPENSSL_KEY_V1 in .env file.'); } - $signature = \hash_hmac('sha256', \json_encode([$projectId, $state['success'] ?? '', $redirectFailure]), $key); + $signature = \hash_hmac('sha256', \json_encode([$projectId, $state['success'] ?? '', $redirectFailure]), $signingKey); if (!\hash_equals($signature, \is_string($state['signature'] ?? null) ? $state['signature'] : '')) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid state parameter. Please restart the installation from the Appwrite Console.'); } diff --git a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Authorize/Get.php b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Authorize/Get.php index f1d48b8618..fb5a28cfaf 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Authorize/Get.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Authorize/Get.php @@ -64,9 +64,9 @@ class Get extends Action Document $project, array $platform ) { - $key = System::getEnv('_APP_OPENSSL_KEY_V1', ''); + $signingKey = System::getEnv('_APP_OPENSSL_KEY_V1', ''); - if (empty($key)) { + if (empty($signingKey)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Signing key is not configured. Please configure _APP_OPENSSL_KEY_V1 in .env file.'); } @@ -76,7 +76,7 @@ class Get extends Action 'projectId' => $project->getId(), 'success' => $success, 'failure' => $failure, - 'signature' => \hash_hmac('sha256', \json_encode([$project->getId(), $success, $failure]), $key), + 'signature' => \hash_hmac('sha256', \json_encode([$project->getId(), $success, $failure]), $signingKey), ]); if (\strlen($state) > APP_LIMIT_VCS_STATE) { diff --git a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Callback/Get.php b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Callback/Get.php index a76ef8d4d4..eb53da9857 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Callback/Get.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Callback/Get.php @@ -70,13 +70,13 @@ class Get extends Action // This endpoint is public -- without verifying the signature the // Authorize action put in state, anyone could pass an arbitrary // projectId here and attach an installation to another project. - $key = System::getEnv('_APP_OPENSSL_KEY_V1', ''); + $signingKey = System::getEnv('_APP_OPENSSL_KEY_V1', ''); - if (empty($key)) { + if (empty($signingKey)) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Signing key is not configured. Please configure _APP_OPENSSL_KEY_V1 in .env file.'); } - $signature = \hash_hmac('sha256', \json_encode([$projectId, $state['success'] ?? '', $redirectFailure]), $key); + $signature = \hash_hmac('sha256', \json_encode([$projectId, $state['success'] ?? '', $redirectFailure]), $signingKey); if (!\hash_equals($signature, \is_string($state['signature'] ?? null) ? $state['signature'] : '')) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid state parameter. Please restart the installation from the Appwrite Console.'); }