Added mv check
This commit is contained in:
parent
51aa84fc26
commit
92409bf4f1
2 changed files with 15 additions and 7 deletions
|
@ -11,6 +11,7 @@ use Utopia\Validator\Text;
|
||||||
use Utopia\Validator\WhiteList;
|
use Utopia\Validator\WhiteList;
|
||||||
use Utopia\Validator\Range;
|
use Utopia\Validator\Range;
|
||||||
use Utopia\Validator\URL;
|
use Utopia\Validator\URL;
|
||||||
|
use Utopia\Domains\Domain;
|
||||||
use Task\Validator\Cron;
|
use Task\Validator\Cron;
|
||||||
use Database\Database;
|
use Database\Database;
|
||||||
use Database\Document;
|
use Database\Document;
|
||||||
|
@ -18,7 +19,6 @@ use Database\Validator\UID;
|
||||||
use OpenSSL\OpenSSL;
|
use OpenSSL\OpenSSL;
|
||||||
use Cron\CronExpression;
|
use Cron\CronExpression;
|
||||||
use Network\Validators\CNAME;
|
use Network\Validators\CNAME;
|
||||||
use Utopia\Domains\Domain;
|
|
||||||
|
|
||||||
include_once __DIR__ . '/../shared/api.php';
|
include_once __DIR__ . '/../shared/api.php';
|
||||||
|
|
||||||
|
@ -1215,6 +1215,12 @@ $utopia->get('/v1/projects/:projectId/xxx')
|
||||||
throw new Exception('Domain already exists', 409);
|
throw new Exception('Domain already exists', 409);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$target = new Domain($request->getServer('_APP_DOMAINS_TARGET', ''));
|
||||||
|
|
||||||
|
if(!$target->isKnown() || $target->isTest()) {
|
||||||
|
throw new Exception('Unreachable CNAME target ('.$target->get().'), plesse use a domain with a public suffix.', 500);
|
||||||
|
}
|
||||||
|
|
||||||
$domain = new Domain($domain);
|
$domain = new Domain($domain);
|
||||||
|
|
||||||
$domain = $consoleDB->createDocument([
|
$domain = $consoleDB->createDocument([
|
||||||
|
@ -1257,7 +1263,7 @@ $utopia->get('/v1/projects/:projectId/domains')
|
||||||
->label('sdk.method', 'listDomains')
|
->label('sdk.method', 'listDomains')
|
||||||
->param('projectId', '', function () { return new UID(); }, 'Project unique ID.')
|
->param('projectId', '', function () { return new UID(); }, 'Project unique ID.')
|
||||||
->action(
|
->action(
|
||||||
function ($projectId) use ($request, $response, $consoleDB) {
|
function ($projectId) use ($response, $consoleDB) {
|
||||||
$project = $consoleDB->getDocument($projectId);
|
$project = $consoleDB->getDocument($projectId);
|
||||||
|
|
||||||
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
|
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
|
||||||
|
|
|
@ -25,9 +25,9 @@ class CertificatesV1
|
||||||
global $request, $consoleDB;
|
global $request, $consoleDB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. Get new domain document
|
* 1. Get new domain document - DONE
|
||||||
* 1.1. Validate domain is valid, public suffix is known and CNAME records are verified
|
* 1.1. Validate domain is valid, public suffix is known and CNAME records are verified - DONE
|
||||||
* 2. Check if a certificate already exists
|
* 2. Check if a certificate already exists - DONE
|
||||||
* 3. Check if certificate is not about to expire skip
|
* 3. Check if certificate is not about to expire skip
|
||||||
* 3.1. Create / renew certificate
|
* 3.1. Create / renew certificate
|
||||||
* 3.2. Update loadblancer
|
* 3.2. Update loadblancer
|
||||||
|
@ -91,7 +91,9 @@ class CertificatesV1
|
||||||
throw new Exception('Failed to issue a certificate');
|
throw new Exception('Failed to issue a certificate');
|
||||||
}
|
}
|
||||||
|
|
||||||
rename('/etc/letsencrypt/live/'.$domain->get(), APP_STORAGE_CERTIFICATES.'/'.$domain->get());
|
if(!rename('/etc/letsencrypt/live/'.$domain->get(), APP_STORAGE_CERTIFICATES.'/'.$domain->get())) {
|
||||||
|
throw new Exception('Failed to copy certificate');
|
||||||
|
}
|
||||||
|
|
||||||
$certificate = array_merge($certificate, [
|
$certificate = array_merge($certificate, [
|
||||||
'$collection' => Database::SYSTEM_COLLECTION_CERTIFICATES,
|
'$collection' => Database::SYSTEM_COLLECTION_CERTIFICATES,
|
||||||
|
|
Loading…
Reference in a new issue