mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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.
This commit is contained in:
1 parent
3fed8989bb
commit
6a316aada7
4 files changed
+12
-12
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user