mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge branch 'main' into upsert-single-document-route
This commit is contained in:
commit
eb05e8c35c
8 changed files with 21 additions and 13 deletions
|
|
@ -478,7 +478,7 @@ return [
|
||||||
'frameworks' => [
|
'frameworks' => [
|
||||||
getFramework('FLUTTER', [
|
getFramework('FLUTTER', [
|
||||||
'providerRootDirectory' => './',
|
'providerRootDirectory' => './',
|
||||||
'buildCommand' => 'bash build.sh',
|
'buildCommand' => 'bash prepare.sh && bash build.sh',
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
'vcsProvider' => 'github',
|
'vcsProvider' => 'github',
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ use Utopia\Logger\Log;
|
||||||
|
|
||||||
interface Adapter
|
interface Adapter
|
||||||
{
|
{
|
||||||
public function issueCertificate(string $certName, string $domain): ?string;
|
public function issueCertificate(string $certName, string $domain, ?string $domainType): ?string;
|
||||||
|
|
||||||
public function isRenewRequired(string $domain, Log $log): bool;
|
public function isRenewRequired(string $domain, ?string $domainType, Log $log): bool;
|
||||||
|
|
||||||
public function deleteCertificate(string $domain): void;
|
public function deleteCertificate(string $domain): void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class LetsEncrypt implements Adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function issueCertificate(string $certName, string $domain): ?string
|
public function issueCertificate(string $certName, string $domain, ?string $domainType): ?string
|
||||||
{
|
{
|
||||||
$stdout = '';
|
$stdout = '';
|
||||||
$stderr = '';
|
$stderr = '';
|
||||||
|
|
@ -84,7 +84,7 @@ class LetsEncrypt implements Adapter
|
||||||
return DateTime::addSeconds($dt, -60 * 60 * 24 * 30);
|
return DateTime::addSeconds($dt, -60 * 60 * 24 * 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isRenewRequired(string $domain, Log $log): bool
|
public function isRenewRequired(string $domain, ?string $domainType, Log $log): bool
|
||||||
{
|
{
|
||||||
$certPath = APP_STORAGE_CERTIFICATES . '/' . $domain . '/cert.pem';
|
$certPath = APP_STORAGE_CERTIFICATES . '/' . $domain . '/cert.pem';
|
||||||
if (\file_exists($certPath)) {
|
if (\file_exists($certPath)) {
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,8 @@ class Create extends Action
|
||||||
if ($rule->getAttribute('status', '') === 'verifying') {
|
if ($rule->getAttribute('status', '') === 'verifying') {
|
||||||
$queueForCertificates
|
$queueForCertificates
|
||||||
->setDomain(new Document([
|
->setDomain(new Document([
|
||||||
'domain' => $rule->getAttribute('domain')
|
'domain' => $rule->getAttribute('domain'),
|
||||||
|
'domainType' => 'api',
|
||||||
]))
|
]))
|
||||||
->trigger();
|
->trigger();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,8 @@ class Create extends Action
|
||||||
if ($rule->getAttribute('status', '') === 'verifying') {
|
if ($rule->getAttribute('status', '') === 'verifying') {
|
||||||
$queueForCertificates
|
$queueForCertificates
|
||||||
->setDomain(new Document([
|
->setDomain(new Document([
|
||||||
'domain' => $rule->getAttribute('domain')
|
'domain' => $rule->getAttribute('domain'),
|
||||||
|
'domainType' => 'function',
|
||||||
]))
|
]))
|
||||||
->trigger();
|
->trigger();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,8 @@ class Create extends Action
|
||||||
if ($rule->getAttribute('status', '') === 'verifying') {
|
if ($rule->getAttribute('status', '') === 'verifying') {
|
||||||
$queueForCertificates
|
$queueForCertificates
|
||||||
->setDomain(new Document([
|
->setDomain(new Document([
|
||||||
'domain' => $rule->getAttribute('domain')
|
'domain' => $rule->getAttribute('domain'),
|
||||||
|
'domainType' => 'redirect',
|
||||||
]))
|
]))
|
||||||
->trigger();
|
->trigger();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,8 @@ class Create extends Action
|
||||||
if ($rule->getAttribute('status', '') === 'verifying') {
|
if ($rule->getAttribute('status', '') === 'verifying') {
|
||||||
$queueForCertificates
|
$queueForCertificates
|
||||||
->setDomain(new Document([
|
->setDomain(new Document([
|
||||||
'domain' => $rule->getAttribute('domain')
|
'domain' => $rule->getAttribute('domain'),
|
||||||
|
'domainType' => 'site',
|
||||||
]))
|
]))
|
||||||
->trigger();
|
->trigger();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class Certificates extends Action
|
||||||
->inject('log')
|
->inject('log')
|
||||||
->inject('certificates')
|
->inject('certificates')
|
||||||
->inject('plan')
|
->inject('plan')
|
||||||
->callback([$this, 'action']);
|
->callback($this->action(...));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -96,11 +96,14 @@ class Certificates extends Action
|
||||||
|
|
||||||
$log->addTag('domain', $domain->get());
|
$log->addTag('domain', $domain->get());
|
||||||
|
|
||||||
$this->execute($domain, $dbForPlatform, $queueForMails, $queueForEvents, $queueForWebhooks, $queueForFunctions, $queueForRealtime, $log, $certificates, $skipRenewCheck, $plan);
|
$domainType = $payload['domainType'] ?? null;
|
||||||
|
|
||||||
|
$this->execute($domain, $domainType, $dbForPlatform, $queueForMails, $queueForEvents, $queueForWebhooks, $queueForFunctions, $queueForRealtime, $log, $certificates, $skipRenewCheck, $plan);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Domain $domain
|
* @param Domain $domain
|
||||||
|
* @param ?string $domainType
|
||||||
* @param Database $dbForPlatform
|
* @param Database $dbForPlatform
|
||||||
* @param Mail $queueForMails
|
* @param Mail $queueForMails
|
||||||
* @param Event $queueForEvents
|
* @param Event $queueForEvents
|
||||||
|
|
@ -115,6 +118,7 @@ class Certificates extends Action
|
||||||
*/
|
*/
|
||||||
private function execute(
|
private function execute(
|
||||||
Domain $domain,
|
Domain $domain,
|
||||||
|
?string $domainType,
|
||||||
Database $dbForPlatform,
|
Database $dbForPlatform,
|
||||||
Mail $queueForMails,
|
Mail $queueForMails,
|
||||||
Event $queueForEvents,
|
Event $queueForEvents,
|
||||||
|
|
@ -174,7 +178,7 @@ class Certificates extends Action
|
||||||
$this->validateDomain($domain, $isMainDomain, $log);
|
$this->validateDomain($domain, $isMainDomain, $log);
|
||||||
|
|
||||||
// If certificate exists already, double-check expiry date. Skip if job is forced
|
// If certificate exists already, double-check expiry date. Skip if job is forced
|
||||||
if (!$certificates->isRenewRequired($domain->get(), $log)) {
|
if (!$certificates->isRenewRequired($domain->get(), $domainType, $log)) {
|
||||||
Console::info("Skipping, renew isn't required");
|
Console::info("Skipping, renew isn't required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +186,7 @@ class Certificates extends Action
|
||||||
|
|
||||||
// Prepare unique cert name. Using this helps prevent miss-match in configuration when renewing certificates.
|
// Prepare unique cert name. Using this helps prevent miss-match in configuration when renewing certificates.
|
||||||
$certName = ID::unique();
|
$certName = ID::unique();
|
||||||
$renewDate = $certificates->issueCertificate($certName, $domain->get());
|
$renewDate = $certificates->issueCertificate($certName, $domain->get(), $domainType);
|
||||||
|
|
||||||
// Command succeeded, store all data into document
|
// Command succeeded, store all data into document
|
||||||
$certificate->setAttribute('logs', 'Certificate successfully generated.');
|
$certificate->setAttribute('logs', 'Certificate successfully generated.');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue