1
0
Fork 0
mirror of synced 2024-06-26 18:20:43 +12:00

Added mv check

This commit is contained in:
Eldad Fux 2020-02-23 19:05:42 +02:00
parent 51aa84fc26
commit 92409bf4f1
2 changed files with 15 additions and 7 deletions

View file

@ -11,6 +11,7 @@ use Utopia\Validator\Text;
use Utopia\Validator\WhiteList;
use Utopia\Validator\Range;
use Utopia\Validator\URL;
use Utopia\Domains\Domain;
use Task\Validator\Cron;
use Database\Database;
use Database\Document;
@ -18,7 +19,6 @@ use Database\Validator\UID;
use OpenSSL\OpenSSL;
use Cron\CronExpression;
use Network\Validators\CNAME;
use Utopia\Domains\Domain;
include_once __DIR__ . '/../shared/api.php';
@ -1215,6 +1215,12 @@ $utopia->get('/v1/projects/:projectId/xxx')
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 = $consoleDB->createDocument([
@ -1257,7 +1263,7 @@ $utopia->get('/v1/projects/:projectId/domains')
->label('sdk.method', 'listDomains')
->param('projectId', '', function () { return new UID(); }, 'Project unique ID.')
->action(
function ($projectId) use ($request, $response, $consoleDB) {
function ($projectId) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {

View file

@ -25,9 +25,9 @@ class CertificatesV1
global $request, $consoleDB;
/**
* 1. Get new domain document
* 1.1. Validate domain is valid, public suffix is known and CNAME records are verified
* 2. Check if a certificate already exists
* 1. Get new domain document - DONE
* 1.1. Validate domain is valid, public suffix is known and CNAME records are verified - DONE
* 2. Check if a certificate already exists - DONE
* 3. Check if certificate is not about to expire skip
* 3.1. Create / renew certificate
* 3.2. Update loadblancer
@ -90,8 +90,10 @@ class CertificatesV1
if(!$response) {
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, [
'$collection' => Database::SYSTEM_COLLECTION_CERTIFICATES,