mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge pull request #10471 from appwrite/feat-certificate-validation-override
Feat: add certificate valdiation override
This commit is contained in:
@@ -9,6 +9,7 @@ class Certificate extends Event
|
||||
{
|
||||
protected bool $skipRenewCheck = false;
|
||||
protected ?Document $domain = null;
|
||||
protected ?string $validationDomain = null;
|
||||
|
||||
public function __construct(protected Publisher $publisher)
|
||||
{
|
||||
@@ -55,6 +56,30 @@ class Certificate extends Event
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set override for main domain used for validation
|
||||
*
|
||||
* @param string|null $validationDomain
|
||||
* @return self
|
||||
*/
|
||||
public function setValidationDomain(?string $validationDomain): self
|
||||
{
|
||||
$this->validationDomain = $validationDomain;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get validation domain
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getValidationDomain(): ?string
|
||||
{
|
||||
return $this->validationDomain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if the certificate needs be validated.
|
||||
*
|
||||
@@ -65,6 +90,7 @@ class Certificate extends Event
|
||||
return $this->skipRenewCheck;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare the payload for the event
|
||||
*
|
||||
@@ -75,7 +101,8 @@ class Certificate extends Event
|
||||
return [
|
||||
'project' => $this->project,
|
||||
'domain' => $this->domain,
|
||||
'skipRenewCheck' => $this->skipRenewCheck
|
||||
'skipRenewCheck' => $this->skipRenewCheck,
|
||||
'validationDomain' => $this->validationDomain
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +93,13 @@ class Certificates extends Action
|
||||
$document = new Document($payload['domain'] ?? []);
|
||||
$domain = new Domain($document->getAttribute('domain', ''));
|
||||
$skipRenewCheck = $payload['skipRenewCheck'] ?? false;
|
||||
$validationDomain = $payload['validationDomain'] ?? null;
|
||||
|
||||
$log->addTag('domain', $domain->get());
|
||||
|
||||
$domainType = $document->getAttribute('domainType');
|
||||
|
||||
$this->execute($domain, $domainType, $dbForPlatform, $queueForMails, $queueForEvents, $queueForWebhooks, $queueForFunctions, $queueForRealtime, $log, $certificates, $skipRenewCheck, $plan);
|
||||
$this->execute($domain, $domainType, $dbForPlatform, $queueForMails, $queueForEvents, $queueForWebhooks, $queueForFunctions, $queueForRealtime, $log, $certificates, $skipRenewCheck, $plan, $validationDomain);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,6 +113,7 @@ class Certificates extends Action
|
||||
* @param CertificatesAdapter $certificates
|
||||
* @param bool $skipRenewCheck
|
||||
* @param array $plan
|
||||
* @param string|null $validationDomain
|
||||
* @return void
|
||||
* @throws Throwable
|
||||
* @throws \Utopia\Database\Exception
|
||||
@@ -128,7 +130,8 @@ class Certificates extends Action
|
||||
Log $log,
|
||||
CertificatesAdapter $certificates,
|
||||
bool $skipRenewCheck = false,
|
||||
array $plan = []
|
||||
array $plan = [],
|
||||
?string $validationDomain = null
|
||||
): void {
|
||||
/**
|
||||
* 1. Read arguments and validate domain
|
||||
@@ -173,7 +176,7 @@ class Certificates extends Action
|
||||
try {
|
||||
// Validate domain and DNS records. Skip if job is forced
|
||||
if (!$skipRenewCheck) {
|
||||
$mainDomain = $this->getMainDomain();
|
||||
$mainDomain = $validationDomain ?? $this->getMainDomain();
|
||||
$isMainDomain = !isset($mainDomain) || $domain->get() === $mainDomain;
|
||||
$this->validateDomain($domain, $isMainDomain, $log);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user