mirror of
https://github.com/appwrite/appwrite
synced 2026-05-21 07:58:55 +00:00
Merge remote-tracking branch 'origin/refactor-auth-single-instance' into refactor-auth-single-instance
This commit is contained in:
commit
b76f01b144
13 changed files with 8958 additions and 22 deletions
|
|
@ -854,7 +854,7 @@ App::get('/v1/cards/cloud')
|
|||
$email = $user->getAttribute('email', '');
|
||||
$createdAt = new \DateTime($user->getCreatedAt());
|
||||
|
||||
$gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $logger, $authorization);
|
||||
$gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $authorization, $logger);
|
||||
$githubName = $gitHub['name'] ?? '';
|
||||
$githubId = $gitHub['id'] ?? '';
|
||||
|
||||
|
|
@ -1061,7 +1061,7 @@ App::get('/v1/cards/cloud-back')
|
|||
$userId = $user->getId();
|
||||
$email = $user->getAttribute('email', '');
|
||||
|
||||
$gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $logger, $authorization);
|
||||
$gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $authorization, $logger);
|
||||
$githubId = $gitHub['id'] ?? '';
|
||||
|
||||
$isHero = \array_key_exists($email, $heroes);
|
||||
|
|
@ -1145,7 +1145,7 @@ App::get('/v1/cards/cloud-og')
|
|||
$email = $user->getAttribute('email', '');
|
||||
$createdAt = new \DateTime($user->getCreatedAt());
|
||||
|
||||
$gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $logger, $authorization);
|
||||
$gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $authorization, $logger);
|
||||
$githubName = $gitHub['name'] ?? '';
|
||||
$githubId = $gitHub['id'] ?? '';
|
||||
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId
|
|||
}
|
||||
}
|
||||
|
||||
ComputeBase::updateEmptyManualRule($project, $resource, $deployment, $dbForPlatform);
|
||||
ComputeBase::updateEmptyManualRule($project, $resource, $deployment, $dbForPlatform, $authorization);
|
||||
|
||||
if ($resource->getCollection() === 'sites' && !empty($latestCommentId) && !empty($previewRuleId)) {
|
||||
$retries = 0;
|
||||
|
|
|
|||
8922
composer.lock
generated
Normal file
8922
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -53,7 +53,7 @@ class Base extends Action
|
|||
return $allowedSpecifications[0] ?? APP_COMPUTE_SPECIFICATION_DEFAULT;
|
||||
}
|
||||
|
||||
public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, Database $dbForPlatform, Build $queueForBuilds, Document $template, GitHub $github, bool $activate, string $referenceType = 'branch', string $reference = ''): Document
|
||||
public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, Database $dbForPlatform, Build $queueForBuilds, Document $template, GitHub $github, bool $activate, Authorization $authorization, string $referenceType = 'branch', string $reference = ''): Document
|
||||
{
|
||||
$deploymentId = ID::unique();
|
||||
$entrypoint = $function->getAttribute('entrypoint', '');
|
||||
|
|
@ -134,7 +134,7 @@ class Base extends Action
|
|||
->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', ''));
|
||||
$dbForProject->updateDocument('functions', $function->getId(), $function);
|
||||
|
||||
$this->updateEmptyManualRule($project, $function, $deployment, $dbForPlatform);
|
||||
$this->updateEmptyManualRule($project, $function, $deployment, $dbForPlatform, $authorization);
|
||||
|
||||
$queueForBuilds
|
||||
->setType(BUILD_TYPE_DEPLOYMENT)
|
||||
|
|
@ -330,7 +330,7 @@ class Base extends Action
|
|||
}
|
||||
}
|
||||
|
||||
$this->updateEmptyManualRule($project, $site, $deployment, $dbForPlatform);
|
||||
$this->updateEmptyManualRule($project, $site, $deployment, $dbForPlatform, $authorization);
|
||||
|
||||
$queueForBuilds
|
||||
->setType(BUILD_TYPE_DEPLOYMENT)
|
||||
|
|
@ -351,7 +351,7 @@ class Base extends Action
|
|||
* @param \Utopia\Database\Database $dbForPlatform
|
||||
* @return void
|
||||
*/
|
||||
public static function updateEmptyManualRule(Document $project, Document $resource, Document $deployment, Database $dbForPlatform)
|
||||
public static function updateEmptyManualRule(Document $project, Document $resource, Document $deployment, Database $dbForPlatform, Authorization $authorization)
|
||||
{
|
||||
$resourceType = $resource->getCollection() === 'sites' ? 'site' : 'function';
|
||||
|
||||
|
|
@ -363,8 +363,8 @@ class Base extends Action
|
|||
Query::equal('type', ['deployment']),
|
||||
Query::equal('trigger', ['manual']),
|
||||
];
|
||||
$dbForPlatform->forEach('rules', function (Document $rule) use ($deployment, $dbForPlatform) {
|
||||
Authorization::skip(fn () => $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([
|
||||
$dbForPlatform->forEach('rules', function (Document $rule) use ($deployment, $dbForPlatform, $authorization) {
|
||||
$authorization->skip(fn () => $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([
|
||||
'deploymentId' => $deployment->getId(),
|
||||
'deploymentInternalId' => $deployment->getSequence(),
|
||||
])));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Utopia\Database\Helpers\ID;
|
|||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Platform\Scope\HTTP;
|
||||
|
|
@ -90,6 +91,7 @@ class Create extends Base
|
|||
->inject('deviceForLocal')
|
||||
->inject('queueForBuilds')
|
||||
->inject('plan')
|
||||
->inject('authorization')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +110,8 @@ class Create extends Base
|
|||
Device $deviceForFunctions,
|
||||
Device $deviceForLocal,
|
||||
Build $queueForBuilds,
|
||||
array $plan
|
||||
array $plan,
|
||||
Authorization $authorization
|
||||
) {
|
||||
$activate = \strval($activate) === 'true' || \strval($activate) === '1';
|
||||
|
||||
|
|
@ -304,7 +307,7 @@ class Create extends Base
|
|||
}
|
||||
}
|
||||
|
||||
$this->updateEmptyManualRule($project, $function, $deployment, $dbForPlatform);
|
||||
$this->updateEmptyManualRule($project, $function, $deployment, $dbForPlatform, $authorization);
|
||||
|
||||
$metadata = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use Utopia\Database\Document;
|
|||
use Utopia\Database\Helpers\ID;
|
||||
use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Platform\Action;
|
||||
use Utopia\Platform\Scope\HTTP;
|
||||
|
|
@ -77,6 +78,7 @@ class Create extends Base
|
|||
->inject('project')
|
||||
->inject('queueForBuilds')
|
||||
->inject('gitHub')
|
||||
->inject('authorization')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +97,8 @@ class Create extends Base
|
|||
Event $queueForEvents,
|
||||
Document $project,
|
||||
Build $queueForBuilds,
|
||||
GitHub $github
|
||||
GitHub $github,
|
||||
Authorization $authorization
|
||||
) {
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
|
|
@ -128,7 +131,10 @@ class Create extends Base
|
|||
queueForBuilds: $queueForBuilds,
|
||||
template: $template,
|
||||
github: $github,
|
||||
activate: $activate
|
||||
activate: $activate,
|
||||
authorization: $authorization,
|
||||
referenceType: $type,
|
||||
reference: $reference
|
||||
);
|
||||
|
||||
$queueForEvents
|
||||
|
|
@ -172,7 +178,7 @@ class Create extends Base
|
|||
$dbForProject->updateDocument('functions', $function->getId(), $function);
|
||||
|
||||
|
||||
$this->updateEmptyManualRule($project, $function, $deployment, $dbForPlatform);
|
||||
$this->updateEmptyManualRule($project, $function, $deployment, $dbForPlatform, $authorization);
|
||||
|
||||
$queueForBuilds
|
||||
->setType(BUILD_TYPE_DEPLOYMENT)
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class Create extends Base
|
|||
->inject('queueForEvents')
|
||||
->inject('queueForBuilds')
|
||||
->inject('gitHub')
|
||||
->inject('authorization')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +88,8 @@ class Create extends Base
|
|||
Document $project,
|
||||
Event $queueForEvents,
|
||||
Build $queueForBuilds,
|
||||
GitHub $github
|
||||
GitHub $github,
|
||||
Authorization $authorization
|
||||
) {
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
|
|
@ -110,6 +112,7 @@ class Create extends Base
|
|||
template: $template,
|
||||
github: $github,
|
||||
activate: $activate,
|
||||
authorization: $authorization,
|
||||
reference: $reference,
|
||||
referenceType: $type
|
||||
);
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ class Create extends Base
|
|||
template: $template,
|
||||
github: $github,
|
||||
activate: true,
|
||||
authorization: $authorization,
|
||||
reference: $providerBranch,
|
||||
referenceType: 'branch'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ class Update extends Base
|
|||
|
||||
// Redeploy logic
|
||||
if (!$isConnected && !empty($providerRepositoryId)) {
|
||||
$this->redeployVcsFunction($request, $function, $project, $installation, $dbForProject, $dbForPlatform, $queueForBuilds, new Document(), $github, true);
|
||||
$this->redeployVcsFunction($request, $function, $project, $installation, $dbForProject, $dbForPlatform, $queueForBuilds, new Document(), $github, true, $authorization);
|
||||
}
|
||||
|
||||
// Inform scheduler if function is still active
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ class Create extends Base
|
|||
}
|
||||
}
|
||||
|
||||
$this->updateEmptyManualRule($project, $site, $deployment, $dbForPlatform);
|
||||
$this->updateEmptyManualRule($project, $site, $deployment, $dbForPlatform, $authorization);
|
||||
|
||||
$metadata = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ class Create extends Base
|
|||
]))
|
||||
);
|
||||
|
||||
$this->updateEmptyManualRule($project, $site, $deployment, $dbForPlatform);
|
||||
$this->updateEmptyManualRule($project, $site, $deployment, $dbForPlatform, $authorization);
|
||||
|
||||
$queueForBuilds
|
||||
->setType(BUILD_TYPE_DEPLOYMENT)
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ class Update extends Base
|
|||
->inject('dbForPlatform')
|
||||
->inject('gitHub')
|
||||
->inject('executor')
|
||||
->inject('authorization')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +128,8 @@ class Update extends Base
|
|||
Build $queueForBuilds,
|
||||
Database $dbForPlatform,
|
||||
GitHub $github,
|
||||
Executor $executor
|
||||
Executor $executor,
|
||||
Authorization $authorization
|
||||
) {
|
||||
if (!empty($adapter)) {
|
||||
$configFramework = Config::getParam('frameworks')[$framework] ?? [];
|
||||
|
|
@ -272,7 +274,7 @@ class Update extends Base
|
|||
|
||||
// Redeploy logic
|
||||
if (!$isConnected && !empty($providerRepositoryId)) {
|
||||
$this->redeployVcsFunction($request, $site, $project, $installation, $dbForProject, $dbForPlatform, $queueForBuilds, new Document(), $github, true);
|
||||
$this->redeployVcsFunction($request, $site, $project, $installation, $dbForProject, $dbForPlatform, $queueForBuilds, new Document(), $github, true, $authorization);
|
||||
}
|
||||
|
||||
$queueForEvents->setParam('siteId', $site->getId());
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ class StatsResources extends Action
|
|||
->inject('dbForPlatform')
|
||||
->inject('logError')
|
||||
->inject('queueForStatsResources')
|
||||
->inject('authorization')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue