mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
Merge pull request #10328 from appwrite/fix-dynamic-key-expiration
Feat: Increase dynamic API key expiration
This commit is contained in:
commit
2ffdfd10d4
4 changed files with 18 additions and 15 deletions
|
|
@ -361,7 +361,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw
|
||||||
$headers['x-appwrite-continent-code'] = '';
|
$headers['x-appwrite-continent-code'] = '';
|
||||||
$headers['x-appwrite-continent-eu'] = 'false';
|
$headers['x-appwrite-continent-eu'] = 'false';
|
||||||
|
|
||||||
$jwtExpiry = $resource->getAttribute('timeout', 900);
|
$jwtExpiry = $resource->getAttribute('timeout', 900) + 60; // 1min extra to account for possible cold-starts
|
||||||
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
||||||
$jwtKey = $jwtObj->encode([
|
$jwtKey = $jwtObj->encode([
|
||||||
'projectId' => $project->getId(),
|
'projectId' => $project->getId(),
|
||||||
|
|
|
||||||
23
composer.lock
generated
23
composer.lock
generated
|
|
@ -758,23 +758,26 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "google/protobuf",
|
"name": "google/protobuf",
|
||||||
"version": "v4.31.1",
|
"version": "v4.32.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/protocolbuffers/protobuf-php.git",
|
"url": "https://github.com/protocolbuffers/protobuf-php.git",
|
||||||
"reference": "2b028ce8876254e2acbeceea7d9b573faad41864"
|
"reference": "9a9a92ecbe9c671dc1863f6d4a91ea3ea12c8646"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/2b028ce8876254e2acbeceea7d9b573faad41864",
|
"url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/9a9a92ecbe9c671dc1863f6d4a91ea3ea12c8646",
|
||||||
"reference": "2b028ce8876254e2acbeceea7d9b573faad41864",
|
"reference": "9a9a92ecbe9c671dc1863f6d4a91ea3ea12c8646",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.0.0"
|
"php": ">=8.1.0"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-protobuf": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": ">=5.0.0"
|
"phpunit/phpunit": ">=5.0.0 <8.5.27"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-bcmath": "Need to support JSON deserialization"
|
"ext-bcmath": "Need to support JSON deserialization"
|
||||||
|
|
@ -796,9 +799,9 @@
|
||||||
"proto"
|
"proto"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.31.1"
|
"source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.32.0"
|
||||||
},
|
},
|
||||||
"time": "2025-05-28T18:52:35+00:00"
|
"time": "2025-08-14T20:00:33+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "league/csv",
|
"name": "league/csv",
|
||||||
|
|
@ -8399,7 +8402,7 @@
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": {},
|
"stability-flags": [],
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
|
|
@ -8423,5 +8426,5 @@
|
||||||
"platform-overrides": {
|
"platform-overrides": {
|
||||||
"php": "8.3"
|
"php": "8.3"
|
||||||
},
|
},
|
||||||
"plugin-api-version": "2.6.0"
|
"plugin-api-version": "2.3.0"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ class Create extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$current->isEmpty()) {
|
if (!$current->isEmpty()) {
|
||||||
$jwtExpiry = $function->getAttribute('timeout', 900);
|
$jwtExpiry = $function->getAttribute('timeout', 900) + 60; // 1min extra to account for possible cold-starts
|
||||||
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
||||||
$jwt = $jwtObj->encode([
|
$jwt = $jwtObj->encode([
|
||||||
'userId' => $user->getId(),
|
'userId' => $user->getId(),
|
||||||
|
|
@ -214,7 +214,7 @@ class Create extends Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$jwtExpiry = $function->getAttribute('timeout', 900);
|
$jwtExpiry = $function->getAttribute('timeout', 900) + 60; // 1min extra to account for possible cold-starts
|
||||||
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
||||||
$apiKey = $jwtObj->encode([
|
$apiKey = $jwtObj->encode([
|
||||||
'projectId' => $project->getId(),
|
'projectId' => $project->getId(),
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ class Functions extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($jwt) && !$user->isEmpty()) {
|
if (empty($jwt) && !$user->isEmpty()) {
|
||||||
$jwtExpiry = $function->getAttribute('timeout', 900);
|
$jwtExpiry = $function->getAttribute('timeout', 900) + 60; // 1min extra to account for possible cold-starts
|
||||||
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
||||||
$jwt = $jwtObj->encode([
|
$jwt = $jwtObj->encode([
|
||||||
'userId' => $user->getId(),
|
'userId' => $user->getId(),
|
||||||
|
|
@ -390,7 +390,7 @@ class Functions extends Action
|
||||||
|
|
||||||
$runtime = $runtimes[$function->getAttribute('runtime')];
|
$runtime = $runtimes[$function->getAttribute('runtime')];
|
||||||
|
|
||||||
$jwtExpiry = $function->getAttribute('timeout', 900);
|
$jwtExpiry = $function->getAttribute('timeout', 900) + 60; // 1min extra to account for possible cold-starts
|
||||||
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', $jwtExpiry, 0);
|
||||||
$apiKey = $jwtObj->encode([
|
$apiKey = $jwtObj->encode([
|
||||||
'projectId' => $project->getId(),
|
'projectId' => $project->getId(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue