From 56e2b7c18b18a332e92654a5a24727b9b14ae799 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 17 Mar 2021 11:04:24 +0545 Subject: [PATCH 01/34] dart 2.12 docker file --- docker/environments/dart-2.12/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 docker/environments/dart-2.12/Dockerfile diff --git a/docker/environments/dart-2.12/Dockerfile b/docker/environments/dart-2.12/Dockerfile new file mode 100644 index 0000000000..06740803a8 --- /dev/null +++ b/docker/environments/dart-2.12/Dockerfile @@ -0,0 +1,9 @@ +FROM google/dart:2.12 + +LABEL maintainer="team@appwrite.io" + +RUN apt-get update -y && apt-get install -y tar + +WORKDIR /usr/local/src/ + +ENV PUB_CACHE=/usr/local/src/.appwrite \ No newline at end of file From f430854e1e01d941a14dca78d0995b028b20b52d Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 17 Mar 2021 11:04:31 +0545 Subject: [PATCH 02/34] dart 2.12 environment support --- app/config/environments.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/config/environments.php b/app/config/environments.php index 9f1c5638e1..3dd4728c45 100644 --- a/app/config/environments.php +++ b/app/config/environments.php @@ -106,6 +106,15 @@ $environments = [ 'logo' => 'dart.png', 'supports' => [System::X86], ], + 'dart-2.12' => [ + 'name' => 'Dart', + 'version' => '2.12', + 'base' => 'google/dart:2.12', + 'image' => 'appwrite/env-dart-2.12:1.0.0', + 'build' => '/usr/src/code/docker/environments/dart-2.12', + 'logo' => 'dart.png', + 'supports' => [System::X86], + ], 'dotnet-3.1' => [ 'name' => '.NET', 'version' => '3.1', From a4be12a13cbfe8f7be28c749dc3deb0bc9617af3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 17 Mar 2021 18:01:34 +0545 Subject: [PATCH 03/34] docker build env --- docker/environments/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/environments/build.sh b/docker/environments/build.sh index 1543c5814d..1385dc9e35 100644 --- a/docker/environments/build.sh +++ b/docker/environments/build.sh @@ -33,6 +33,9 @@ docker buildx build --platform linux/amd64,linux/arm64,linux/386,linux/ppc64le - echo 'Dart 2.10...' docker buildx build --platform linux/amd64 -t appwrite/env-dart-2.10:1.0.0 ./docker/environments/dart-2.10/ --push +echo 'Dart 2.12...' +docker buildx build --platform linux/amd64 -t appwrite/env-dart-2.12:1.0.0 ./docker/environments/dart-2.12/ --push + echo '.NET 3.1...' docker buildx build --platform linux/amd64,linux/arm64 -t appwrite/env-dotnet-3.1:1.0.0 ./docker/environments/dotnet-3.1/ --push From c8c4b11dad60b1a70c9a153d7cc1d199422d3d54 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 17 Mar 2021 18:13:42 +0545 Subject: [PATCH 04/34] test for dart 2.12 --- .../e2e/Services/Functions/FunctionsCustomServerTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 9dded8fdd7..c641c3805d 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -541,6 +541,14 @@ class FunctionsCustomServerTest extends Scope 'command' => 'dart main.dart', 'timeout' => 15, ], + [ + 'language' => 'Dart', + 'version' => '2.12', + 'name' => 'dart-2.12', + 'code' => $functions.'/dart.tar.gz', + 'command' => 'dart main.dart', + 'timeout' => 15, + ], [ 'language' => '.NET', 'version' => '3.1', From b262ebfeb3d7384187f377aca92e211ce7248f69 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 23 Mar 2021 13:27:51 -0400 Subject: [PATCH 05/34] Move validators from utopia --- src/Appwrite/Network/Validator/Email.php | 66 ++++++++++++ src/Appwrite/Network/Validator/Host.php | 82 ++++++++++++++ src/Appwrite/Network/Validator/IP.php | 112 ++++++++++++++++++++ src/Appwrite/Network/Validator/URL.php | 66 ++++++++++++ tests/unit/Network/Validators/EmailTest.php | 71 +++++++++++++ tests/unit/Network/Validators/HostTest.php | 45 ++++++++ tests/unit/Network/Validators/IPTest.php | 81 ++++++++++++++ tests/unit/Network/Validators/URLTest.php | 48 +++++++++ 8 files changed, 571 insertions(+) create mode 100644 src/Appwrite/Network/Validator/Email.php create mode 100644 src/Appwrite/Network/Validator/Host.php create mode 100644 src/Appwrite/Network/Validator/IP.php create mode 100644 src/Appwrite/Network/Validator/URL.php create mode 100755 tests/unit/Network/Validators/EmailTest.php create mode 100755 tests/unit/Network/Validators/HostTest.php create mode 100755 tests/unit/Network/Validators/IPTest.php create mode 100755 tests/unit/Network/Validators/URLTest.php diff --git a/src/Appwrite/Network/Validator/Email.php b/src/Appwrite/Network/Validator/Email.php new file mode 100644 index 0000000000..451e8e3b00 --- /dev/null +++ b/src/Appwrite/Network/Validator/Email.php @@ -0,0 +1,66 @@ + + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use Utopia\Validator; + +/** + * Email + * + * Validate that an variable is a valid email address + * + * @package Utopia\Validator + */ +class Email extends Validator +{ + /** + * Get Description + * + * Returns validator description + * + * @return string + */ + public function getDescription() + { + return 'Value must be a valid email address'; + } + + /** + * Get Type + * + * Returns validator type. + * + * @return string + */ + public function getType() + { + return self::TYPE_STRING; + } + + /** + * Is valid + * + * Validation will pass when $value is valid email address. + * + * @param mixed $value + * @return bool + */ + public function isValid($value) + { + if (!\filter_var($value, FILTER_VALIDATE_EMAIL)) { + return false; + } + + return true; + } +} diff --git a/src/Appwrite/Network/Validator/Host.php b/src/Appwrite/Network/Validator/Host.php new file mode 100644 index 0000000000..54c9ebbd2f --- /dev/null +++ b/src/Appwrite/Network/Validator/Host.php @@ -0,0 +1,82 @@ + + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use Utopia\Validator; + +/** + * Host + * + * Validate that a host is allowed from given whitelisted hosts list + * + * @package Utopia\Validator + */ +class Host extends Validator +{ + protected $whitelist = []; + + /** + * @param array $whitelist + */ + public function __construct(array $whitelist) + { + $this->whitelist = $whitelist; + } + + /** + * Get Description + * + * Returns validator description + * + * @return string + */ + public function getDescription() + { + return 'URL host must be one of: ' . \implode(', ', $this->whitelist); + } + + /** + * Get Type + * + * Returns validator type. + * + * @return string + */ + public function getType() + { + return self::TYPE_STRING; + } + + /** + * Is valid + * + * Validation will pass when $value starts with one of the given hosts + * + * @param mixed $value + * @return bool + */ + public function isValid($value) + { + $urlValidator = new URL(); + + if (!$urlValidator->isValid($value)) { + return false; + } + + if (\in_array(\parse_url($value, PHP_URL_HOST), $this->whitelist)) { + return true; + } + + return false; + } +} diff --git a/src/Appwrite/Network/Validator/IP.php b/src/Appwrite/Network/Validator/IP.php new file mode 100644 index 0000000000..b1ea727795 --- /dev/null +++ b/src/Appwrite/Network/Validator/IP.php @@ -0,0 +1,112 @@ + + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use Exception; +use Utopia\Validator; + +/** + * IP + * + * Validate that an variable is a valid IP address + * + * @package Utopia\Validator + */ +class IP extends Validator +{ + const ALL = 'all'; + const V4 = 'ipv4'; + const V6 = 'ipv6'; + + /** + * @var string + */ + protected $type = self::ALL; + + /** + * Constructor + * + * Set a the type of IP check. + * + * @param string $type + */ + public function __construct(string $type = self::ALL) + { + if (!in_array($type, [self::ALL, self::V4, self::V6])) { + throw new Exception('Unsupported IP type'); + } + + $this->type = $type; + } + + /** + * Get Description + * + * Returns validator description + * + * @return string + */ + public function getDescription() + { + return 'Value must be a valid IP address'; + } + + /** + * Get Type + * + * Returns validator type. + * + * @return string + */ + public function getType() + { + return self::TYPE_STRING; + } + + /** + * Is valid + * + * Validation will pass when $value is valid IP address. + * + * @param mixed $value + * @return bool + */ + public function isValid($value) + { + switch ($this->type) { + case self::ALL: + if (\filter_var($value, FILTER_VALIDATE_IP)) { + return true; + } + break; + + case self::V4: + if (\filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + return true; + } + break; + + case self::V6: + if (\filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + return true; + } + break; + + default: + return false; + break; + } + + return false; + } +} diff --git a/src/Appwrite/Network/Validator/URL.php b/src/Appwrite/Network/Validator/URL.php new file mode 100644 index 0000000000..a610928d79 --- /dev/null +++ b/src/Appwrite/Network/Validator/URL.php @@ -0,0 +1,66 @@ + + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use Utopia\Validator; + +/** + * URL + * + * Validate that an variable is a valid URL + * + * @package Utopia\Validator + */ +class URL extends Validator +{ + /** + * Get Description + * + * Returns validator description + * + * @return string + */ + public function getDescription() + { + return 'Value must be a valid URL'; + } + + /** + * Get Type + * + * Returns validator type. + * + * @return string + */ + public function getType() + { + return self::TYPE_STRING; + } + + /** + * Is valid + * + * Validation will pass when $value is valid URL. + * + * @param mixed $value + * @return bool + */ + public function isValid($value) + { + if (\filter_var($value, FILTER_VALIDATE_URL) === false) { + return false; + } + + return true; + } +} diff --git a/tests/unit/Network/Validators/EmailTest.php b/tests/unit/Network/Validators/EmailTest.php new file mode 100755 index 0000000000..03e4d043c5 --- /dev/null +++ b/tests/unit/Network/Validators/EmailTest.php @@ -0,0 +1,71 @@ + + * @version 1.0 RC4 + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use PHPUnit\Framework\TestCase; + +class EmailTest extends TestCase +{ + /** + * @var Email + */ + protected $email = null; + + public function setUp():void + { + $this->email = new Email(); + } + + public function tearDown():void + { + $this->email = null; + } + + public function testIsValid() + { + // Assertions + $this->assertEquals(true, $this->email->isValid('email@domain.com')); + $this->assertEquals(true, $this->email->isValid('firstname.lastname@domain.com')); + $this->assertEquals(true, $this->email->isValid('email@subdomain.domain.com')); + $this->assertEquals(true, $this->email->isValid('firstname+lastname@domain.com')); + $this->assertEquals(true, $this->email->isValid('email@[123.123.123.123]')); + $this->assertEquals(true, $this->email->isValid('"email"@domain.com')); + $this->assertEquals(true, $this->email->isValid('1234567890@domain.com')); + $this->assertEquals(true, $this->email->isValid('email@domain-one.com')); + $this->assertEquals(true, $this->email->isValid('_______@domain.com')); + $this->assertEquals(true, $this->email->isValid('email@domain.name')); + $this->assertEquals(true, $this->email->isValid('email@domain.co.jp')); + $this->assertEquals(true, $this->email->isValid('firstname-lastname@domain.com')); + $this->assertEquals(false, $this->email->isValid(false)); + $this->assertEquals(false, $this->email->isValid(['string', 'string'])); + $this->assertEquals(false, $this->email->isValid(1)); + $this->assertEquals(false, $this->email->isValid(1.2)); + $this->assertEquals(false, $this->email->isValid('plainaddress')); // Missing @ sign and domain + $this->assertEquals(false, $this->email->isValid('@domain.com')); // Missing username + $this->assertEquals(false, $this->email->isValid('#@%^%#$@#$@#.com')); // Garbage + $this->assertEquals(false, $this->email->isValid('Joe Smith ')); // Encoded html within email is invalid + $this->assertEquals(false, $this->email->isValid('email.domain.com')); // Missing @ + $this->assertEquals(false, $this->email->isValid('email@domain@domain.com')); // Two @ sign + $this->assertEquals(false, $this->email->isValid('.email@domain.com')); // Leading dot in address is not allowed + $this->assertEquals(false, $this->email->isValid('email.@domain.com')); // Trailing dot in address is not allowed + $this->assertEquals(false, $this->email->isValid('email..email@domain.com')); // Multiple dots + $this->assertEquals(false, $this->email->isValid('あいうえお@domain.com')); // Unicode char as address + $this->assertEquals(false, $this->email->isValid('email@domain.com (Joe Smith)')); // Text followed email is not allowed + $this->assertEquals(false, $this->email->isValid('email@domain')); // Missing top level domain (.com/.net/.org/etc) + $this->assertEquals(false, $this->email->isValid('email@-domain.com')); // Leading dash in front of domain is invalid + $this->assertEquals(false, $this->email->isValid('email@111.222.333.44444')); // Invalid IP format + $this->assertEquals(false, $this->email->isValid('email@domain..com')); // Multiple dot in the domain portion is invalid + $this->assertEquals($this->email->getType(), 'string'); + } +} diff --git a/tests/unit/Network/Validators/HostTest.php b/tests/unit/Network/Validators/HostTest.php new file mode 100755 index 0000000000..dbaf83b7b8 --- /dev/null +++ b/tests/unit/Network/Validators/HostTest.php @@ -0,0 +1,45 @@ + + * @version 1.0 RC4 + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use PHPUnit\Framework\TestCase; + +class HostTest extends TestCase +{ + /** + * @var Host + */ + protected $host = null; + + public function setUp():void + { + $this->host = new Host(['appwrite.io', 'subdomain.appwrite.test', 'localhost']); + } + + public function tearDown():void + { + $this->host = null; + } + + public function testIsValid() + { + // Assertions + $this->assertEquals($this->host->isValid('https://appwrite.io/link'), true); + $this->assertEquals($this->host->isValid('https://localhost'), true); + $this->assertEquals($this->host->isValid('localhost'), false); + $this->assertEquals($this->host->isValid('http://subdomain.appwrite.test/path'), true); + $this->assertEquals($this->host->isValid('http://test.subdomain.appwrite.test/path'), false); + $this->assertEquals($this->host->getType(), 'string'); + } +} diff --git a/tests/unit/Network/Validators/IPTest.php b/tests/unit/Network/Validators/IPTest.php new file mode 100755 index 0000000000..1be8f78ab3 --- /dev/null +++ b/tests/unit/Network/Validators/IPTest.php @@ -0,0 +1,81 @@ + + * @version 1.0 RC4 + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use PHPUnit\Framework\TestCase; + +class IPTest extends TestCase +{ + public function tearDown():void + { + $this->validator = null; + } + + public function testIsValidIP() + { + $validator = new IP(); + + // Assertions + $this->assertEquals($validator->isValid('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'), true); + $this->assertEquals($validator->isValid('109.67.204.101'), true); + $this->assertEquals($validator->isValid(23.5), false); + $this->assertEquals($validator->isValid('23.5'), false); + $this->assertEquals($validator->isValid(null), false); + $this->assertEquals($validator->isValid(true), false); + $this->assertEquals($validator->isValid(false), false); + $this->assertEquals($validator->getType(), 'string'); + } + + public function testIsValidIPALL() + { + $validator = new IP(IP::ALL); + + // Assertions + $this->assertEquals($validator->isValid('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'), true); + $this->assertEquals($validator->isValid('109.67.204.101'), true); + $this->assertEquals($validator->isValid(23.5), false); + $this->assertEquals($validator->isValid('23.5'), false); + $this->assertEquals($validator->isValid(null), false); + $this->assertEquals($validator->isValid(true), false); + $this->assertEquals($validator->isValid(false), false); + } + + public function testIsValidIPV4() + { + $validator = new IP(IP::V4); + + // Assertions + $this->assertEquals($validator->isValid('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'), false); + $this->assertEquals($validator->isValid('109.67.204.101'), true); + $this->assertEquals($validator->isValid(23.5), false); + $this->assertEquals($validator->isValid('23.5'), false); + $this->assertEquals($validator->isValid(null), false); + $this->assertEquals($validator->isValid(true), false); + $this->assertEquals($validator->isValid(false), false); + } + + public function testIsValidIPV6() + { + $validator = new IP(IP::V6); + + // Assertions + $this->assertEquals($validator->isValid('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'), true); + $this->assertEquals($validator->isValid('109.67.204.101'), false); + $this->assertEquals($validator->isValid(23.5), false); + $this->assertEquals($validator->isValid('23.5'), false); + $this->assertEquals($validator->isValid(null), false); + $this->assertEquals($validator->isValid(true), false); + $this->assertEquals($validator->isValid(false), false); + } +} diff --git a/tests/unit/Network/Validators/URLTest.php b/tests/unit/Network/Validators/URLTest.php new file mode 100755 index 0000000000..cd4844f7c9 --- /dev/null +++ b/tests/unit/Network/Validators/URLTest.php @@ -0,0 +1,48 @@ + + * @version 1.0 RC4 + * @license The MIT License (MIT) + */ + +namespace Utopia\Validator; + +use PHPUnit\Framework\TestCase; + +class URLTest extends TestCase +{ + /** + * @var Domain + */ + protected $url = null; + + public function setUp():void + { + $this->url = new URL(); + } + + public function tearDown():void + { + $this->url = null; + } + + public function testIsValid() + { + // Assertions + $this->assertEquals(true, $this->url->isValid('http://example.com')); + $this->assertEquals(true, $this->url->isValid('https://example.com')); + $this->assertEquals(true, $this->url->isValid('htts://example.com')); // does not validate protocol + $this->assertEquals(false, $this->url->isValid('example.com')); // though, requires some kind of protocol + $this->assertEquals(false, $this->url->isValid('http:/example.com')); + $this->assertEquals(true, $this->url->isValid('http://exa-mple.com')); + $this->assertEquals(false, $this->url->isValid('htt@s://example.com')); + $this->assertEquals(true, $this->url->isValid('http://www.example.com/foo%2\u00c2\u00a9zbar')); + $this->assertEquals(true, $this->url->isValid('http://www.example.com/?q=%3Casdf%3E')); + } +} From 7f485ce53622b9227a653a706dade94dc8db774d Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 24 Mar 2021 13:47:17 -0400 Subject: [PATCH 06/34] Update validator namespaces --- src/Appwrite/Network/Validator/Email.php | 2 +- src/Appwrite/Network/Validator/Host.php | 2 +- src/Appwrite/Network/Validator/IP.php | 2 +- src/Appwrite/Network/Validator/URL.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Network/Validator/Email.php b/src/Appwrite/Network/Validator/Email.php index 451e8e3b00..85ec99b07d 100644 --- a/src/Appwrite/Network/Validator/Email.php +++ b/src/Appwrite/Network/Validator/Email.php @@ -10,7 +10,7 @@ * @license The MIT License (MIT) */ -namespace Utopia\Validator; +namespace Appwrite\Network\Validator; use Utopia\Validator; diff --git a/src/Appwrite/Network/Validator/Host.php b/src/Appwrite/Network/Validator/Host.php index 54c9ebbd2f..0a912a77b0 100644 --- a/src/Appwrite/Network/Validator/Host.php +++ b/src/Appwrite/Network/Validator/Host.php @@ -10,7 +10,7 @@ * @license The MIT License (MIT) */ -namespace Utopia\Validator; +namespace Appwrite\Network\Validator; use Utopia\Validator; diff --git a/src/Appwrite/Network/Validator/IP.php b/src/Appwrite/Network/Validator/IP.php index b1ea727795..8fed45dca0 100644 --- a/src/Appwrite/Network/Validator/IP.php +++ b/src/Appwrite/Network/Validator/IP.php @@ -10,7 +10,7 @@ * @license The MIT License (MIT) */ -namespace Utopia\Validator; +namespace Appwrite\Network\Validator; use Exception; use Utopia\Validator; diff --git a/src/Appwrite/Network/Validator/URL.php b/src/Appwrite/Network/Validator/URL.php index a610928d79..b7907da71b 100644 --- a/src/Appwrite/Network/Validator/URL.php +++ b/src/Appwrite/Network/Validator/URL.php @@ -10,7 +10,7 @@ * @license The MIT License (MIT) */ -namespace Utopia\Validator; +namespace Appwrite\Network\Validator; use Utopia\Validator; From 07140bda5a92298b858ac0e3f7ca106b74ff7178 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 24 Mar 2021 13:47:43 -0400 Subject: [PATCH 07/34] Replace utopia libs with native validators --- app/controllers/api/account.php | 6 +++--- app/controllers/api/avatars.php | 2 +- app/controllers/api/projects.php | 2 +- app/controllers/api/teams.php | 4 ++-- app/controllers/api/users.php | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index fd09aaa3d5..0a26151993 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -6,10 +6,10 @@ use Utopia\Exception; use Utopia\Config\Config; use Utopia\Validator\Assoc; use Utopia\Validator\Text; -use Utopia\Validator\Email; +use Appwrite\Network\Validator\Email; use Utopia\Validator\WhiteList; -use Utopia\Validator\Host; -use Utopia\Validator\URL; +use Appwrite\Network\Validator\Host; +use Appwrite\Network\Validator\URL; use Utopia\Audit\Audit; use Utopia\Audit\Adapters\MySQL as AuditAdapter; use Appwrite\Auth\Auth; diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index a094dc672a..b5c47c1987 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -14,7 +14,7 @@ use Utopia\Validator\Boolean; use Utopia\Validator\HexColor; use Utopia\Validator\Range; use Utopia\Validator\Text; -use Utopia\Validator\URL; +use Appwrite\Network\Validator\URL; use Utopia\Validator\WhiteList; $avatarCallback = function ($type, $code, $width, $height, $quality, $response) { diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 63c99ffaee..5737714610 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -6,7 +6,7 @@ use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; -use Utopia\Validator\URL; +use Appwrite\Network\Validator\URL; use Utopia\Validator\Range; use Utopia\Config\Config; use Utopia\Domains\Domain; diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index c4a9e4875d..847b37484d 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -3,9 +3,9 @@ use Utopia\App; use Utopia\Exception; use Utopia\Config\Config; -use Utopia\Validator\Email; +use Appwrite\Network\Validator\Email; use Utopia\Validator\Text; -use Utopia\Validator\Host; +use Appwrite\Network\Validator\Host; use Utopia\Validator\Range; use Utopia\Validator\ArrayList; use Utopia\Validator\WhiteList; diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 958dfc1488..58ec3ee978 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -4,7 +4,7 @@ use Utopia\App; use Utopia\Exception; use Utopia\Validator\Assoc; use Utopia\Validator\WhiteList; -use Utopia\Validator\Email; +use Appwrite\Network\Validator\Email; use Utopia\Validator\Text; use Utopia\Validator\Range; use Utopia\Audit\Audit; From 31bf1bdcef6c58b6d43e671389424f56c0d2776f Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 24 Mar 2021 14:34:47 -0400 Subject: [PATCH 08/34] Update validator namespaces --- tests/unit/Network/Validators/EmailTest.php | 2 +- tests/unit/Network/Validators/HostTest.php | 2 +- tests/unit/Network/Validators/IPTest.php | 2 +- tests/unit/Network/Validators/URLTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/Network/Validators/EmailTest.php b/tests/unit/Network/Validators/EmailTest.php index 03e4d043c5..5a7bf0f963 100755 --- a/tests/unit/Network/Validators/EmailTest.php +++ b/tests/unit/Network/Validators/EmailTest.php @@ -11,7 +11,7 @@ * @license The MIT License (MIT) */ -namespace Utopia\Validator; +namespace Appwrite\Network\Validator; use PHPUnit\Framework\TestCase; diff --git a/tests/unit/Network/Validators/HostTest.php b/tests/unit/Network/Validators/HostTest.php index dbaf83b7b8..724ad74152 100755 --- a/tests/unit/Network/Validators/HostTest.php +++ b/tests/unit/Network/Validators/HostTest.php @@ -11,7 +11,7 @@ * @license The MIT License (MIT) */ -namespace Utopia\Validator; +namespace Appwrite\Network\Validator; use PHPUnit\Framework\TestCase; diff --git a/tests/unit/Network/Validators/IPTest.php b/tests/unit/Network/Validators/IPTest.php index 1be8f78ab3..8ebd12dd03 100755 --- a/tests/unit/Network/Validators/IPTest.php +++ b/tests/unit/Network/Validators/IPTest.php @@ -11,7 +11,7 @@ * @license The MIT License (MIT) */ -namespace Utopia\Validator; +namespace Appwrite\Network\Validator; use PHPUnit\Framework\TestCase; diff --git a/tests/unit/Network/Validators/URLTest.php b/tests/unit/Network/Validators/URLTest.php index cd4844f7c9..458637da67 100755 --- a/tests/unit/Network/Validators/URLTest.php +++ b/tests/unit/Network/Validators/URLTest.php @@ -11,7 +11,7 @@ * @license The MIT License (MIT) */ -namespace Utopia\Validator; +namespace Appwrite\Network\Validator; use PHPUnit\Framework\TestCase; From 448276fcd485f3e58a65e4bca8a8bf5fb37be7db Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 24 Mar 2021 14:35:36 -0400 Subject: [PATCH 09/34] Validator constants not defined --- src/Appwrite/Network/Validator/Email.php | 2 +- src/Appwrite/Network/Validator/Host.php | 2 +- src/Appwrite/Network/Validator/IP.php | 2 +- src/Appwrite/Network/Validator/URL.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Network/Validator/Email.php b/src/Appwrite/Network/Validator/Email.php index 85ec99b07d..1736ac8172 100644 --- a/src/Appwrite/Network/Validator/Email.php +++ b/src/Appwrite/Network/Validator/Email.php @@ -44,7 +44,7 @@ class Email extends Validator */ public function getType() { - return self::TYPE_STRING; + return 'string'; } /** diff --git a/src/Appwrite/Network/Validator/Host.php b/src/Appwrite/Network/Validator/Host.php index 0a912a77b0..145e4eb7ed 100644 --- a/src/Appwrite/Network/Validator/Host.php +++ b/src/Appwrite/Network/Validator/Host.php @@ -54,7 +54,7 @@ class Host extends Validator */ public function getType() { - return self::TYPE_STRING; + return 'string'; } /** diff --git a/src/Appwrite/Network/Validator/IP.php b/src/Appwrite/Network/Validator/IP.php index 8fed45dca0..c1d1402dbd 100644 --- a/src/Appwrite/Network/Validator/IP.php +++ b/src/Appwrite/Network/Validator/IP.php @@ -70,7 +70,7 @@ class IP extends Validator */ public function getType() { - return self::TYPE_STRING; + return 'string'; } /** diff --git a/src/Appwrite/Network/Validator/URL.php b/src/Appwrite/Network/Validator/URL.php index b7907da71b..0a2a1326ed 100644 --- a/src/Appwrite/Network/Validator/URL.php +++ b/src/Appwrite/Network/Validator/URL.php @@ -44,7 +44,7 @@ class URL extends Validator */ public function getType() { - return self::TYPE_STRING; + return 'string'; } /** From 30fc7df975aeba531e32a4769d700f09d76e45c6 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 29 Mar 2021 13:14:20 +0545 Subject: [PATCH 10/34] python functions env 3.9 --- app/config/environments.php | 9 +++++++++ docker/environments/build.sh | 3 +++ docker/environments/python-3.9/Dockerfile | 11 +++++++++++ .../Services/Functions/FunctionsCustomServerTest.php | 8 ++++++++ 4 files changed, 31 insertions(+) create mode 100644 docker/environments/python-3.9/Dockerfile diff --git a/app/config/environments.php b/app/config/environments.php index 9f1c5638e1..c74db6fd35 100644 --- a/app/config/environments.php +++ b/app/config/environments.php @@ -70,6 +70,15 @@ $environments = [ 'logo' => 'python.png', 'supports' => [System::X86, System::PPC, System::ARM], ], + 'python-3.9' => [ + 'name' => 'Python', + 'version' => '3.9', + 'base' => 'python:3.9-alpine', + 'image' => 'appwrite/env-python-3.9:1.0.0', + 'build' => '/usr/src/code/docker/environments/python-3.9', + 'logo' => 'python.png', + 'supports' => [System::X86, System::PPC, System::ARM], + ], 'deno-1.2' => [ 'name' => 'Deno', 'version' => '1.2', diff --git a/docker/environments/build.sh b/docker/environments/build.sh index 1543c5814d..175389847f 100644 --- a/docker/environments/build.sh +++ b/docker/environments/build.sh @@ -24,6 +24,9 @@ docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 echo 'Python 3.8...' docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le -t appwrite/env-python-3.8:1.0.0 ./docker/environments/python-3.8/ --push +echo 'Python 3.9...' +docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le -t appwrite/env-python-3.9:1.0.0 ./docker/environments/python-3.9/ --push + echo 'Ruby 2.7...' docker buildx build --platform linux/amd64,linux/arm64,linux/386,linux/ppc64le -t appwrite/env-ruby-2.7:1.0.2 ./docker/environments/ruby-2.7/ --push diff --git a/docker/environments/python-3.9/Dockerfile b/docker/environments/python-3.9/Dockerfile new file mode 100644 index 0000000000..94b7b8ceb8 --- /dev/null +++ b/docker/environments/python-3.9/Dockerfile @@ -0,0 +1,11 @@ +FROM python:3.9-alpine + +LABEL maintainer="team@appwrite.io" + +RUN apk add tar + +RUN mkdir /usr/local/src + +WORKDIR /usr/local/src/ + +ENV PYTHONPATH "${PYTHONPATH}:/usr/local/src/.appwrite" \ No newline at end of file diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index b04a635cf0..08f2f046dd 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -485,6 +485,14 @@ class FunctionsCustomServerTest extends Scope 'command' => 'python main.py', 'timeout' => 15, ], + [ + 'language' => 'Python', + 'version' => '3.9', + 'name' => 'python-3.9', + 'code' => $functions.'/python.tar.gz', + 'command' => 'python main.py', + 'timeout' => 15, + ], [ 'language' => 'Node.js', 'version' => '14.5', From c49166248795cf49860f6934f06fe6c65a134750 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 30 Mar 2021 07:25:21 -0400 Subject: [PATCH 11/34] Remove utopia license comments --- src/Appwrite/Network/Validator/Email.php | 10 ---------- src/Appwrite/Network/Validator/Host.php | 10 ---------- src/Appwrite/Network/Validator/IP.php | 10 ---------- src/Appwrite/Network/Validator/URL.php | 10 ---------- 4 files changed, 40 deletions(-) diff --git a/src/Appwrite/Network/Validator/Email.php b/src/Appwrite/Network/Validator/Email.php index 1736ac8172..ca9ba1d53d 100644 --- a/src/Appwrite/Network/Validator/Email.php +++ b/src/Appwrite/Network/Validator/Email.php @@ -1,14 +1,4 @@ - * @license The MIT License (MIT) - */ namespace Appwrite\Network\Validator; diff --git a/src/Appwrite/Network/Validator/Host.php b/src/Appwrite/Network/Validator/Host.php index 145e4eb7ed..f746ecd752 100644 --- a/src/Appwrite/Network/Validator/Host.php +++ b/src/Appwrite/Network/Validator/Host.php @@ -1,14 +1,4 @@ - * @license The MIT License (MIT) - */ namespace Appwrite\Network\Validator; diff --git a/src/Appwrite/Network/Validator/IP.php b/src/Appwrite/Network/Validator/IP.php index c1d1402dbd..523147eb2d 100644 --- a/src/Appwrite/Network/Validator/IP.php +++ b/src/Appwrite/Network/Validator/IP.php @@ -1,14 +1,4 @@ - * @license The MIT License (MIT) - */ namespace Appwrite\Network\Validator; diff --git a/src/Appwrite/Network/Validator/URL.php b/src/Appwrite/Network/Validator/URL.php index 0a2a1326ed..bd1546e111 100644 --- a/src/Appwrite/Network/Validator/URL.php +++ b/src/Appwrite/Network/Validator/URL.php @@ -1,14 +1,4 @@ - * @license The MIT License (MIT) - */ namespace Appwrite\Network\Validator; From 1c9fbf0b1713ee45b0dd450b4f42423b7ae01434 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 31 Mar 2021 07:15:25 +0545 Subject: [PATCH 12/34] self signed certs on readmes --- docs/sdks/dart/GETTING_STARTED.md | 1 + docs/sdks/deno/GETTING_STARTED.md | 2 ++ docs/sdks/dotnet/GETTING_STARTED.md | 1 + docs/sdks/flutter/GETTING_STARTED.md | 4 ++-- docs/sdks/nodejs/GETTING_STARTED.md | 2 ++ docs/sdks/php/GETTING_STARTED.md | 2 ++ docs/sdks/python/GETTING_STARTED.md | 2 ++ docs/sdks/ruby/GETTING_STARTED.md | 2 ++ docs/sdks/web/GETTING_STARTED.md | 2 ++ 9 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/sdks/dart/GETTING_STARTED.md b/docs/sdks/dart/GETTING_STARTED.md index 56297a2e5e..5318c8ce1b 100644 --- a/docs/sdks/dart/GETTING_STARTED.md +++ b/docs/sdks/dart/GETTING_STARTED.md @@ -11,6 +11,7 @@ void main() async { .setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible .setProject('5ff3379a01d25') // Your project ID .setKey('cd868c7af8bdc893b4...93b7535db89') + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert Users users = Users(client); diff --git a/docs/sdks/deno/GETTING_STARTED.md b/docs/sdks/deno/GETTING_STARTED.md index bfe40468b3..b8f851a4b9 100644 --- a/docs/sdks/deno/GETTING_STARTED.md +++ b/docs/sdks/deno/GETTING_STARTED.md @@ -10,6 +10,7 @@ client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; ``` @@ -41,6 +42,7 @@ client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; let promise = users.create('email@example.com', 'password'); diff --git a/docs/sdks/dotnet/GETTING_STARTED.md b/docs/sdks/dotnet/GETTING_STARTED.md index 66dca9ff3f..4363c68204 100644 --- a/docs/sdks/dotnet/GETTING_STARTED.md +++ b/docs/sdks/dotnet/GETTING_STARTED.md @@ -14,6 +14,7 @@ static async Task Main(string[] args) .setEndpoint('http://[HOSTNAME_OR_IP]/v1') // Make sure your endpoint is accessible .setProject('5ff3379a01d25') // Your project ID .setKey('cd868c7af8bdc893b4...93b7535db89') + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; var users = Users(client); diff --git a/docs/sdks/flutter/GETTING_STARTED.md b/docs/sdks/flutter/GETTING_STARTED.md index 78845f3e18..9af9720d89 100644 --- a/docs/sdks/flutter/GETTING_STARTED.md +++ b/docs/sdks/flutter/GETTING_STARTED.md @@ -58,7 +58,7 @@ Client client = Client(); client .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint .setProject('5e8cf4f46b5e8') // Your project ID - .setSelfSigned() // Remove in production + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; ``` @@ -91,7 +91,7 @@ Client client = Client(); client .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint .setProject('5e8cf4f46b5e8') // Your project ID - .setSelfSigned() // Remove in production + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; diff --git a/docs/sdks/nodejs/GETTING_STARTED.md b/docs/sdks/nodejs/GETTING_STARTED.md index 1053f28142..b2ce5f091c 100644 --- a/docs/sdks/nodejs/GETTING_STARTED.md +++ b/docs/sdks/nodejs/GETTING_STARTED.md @@ -12,6 +12,7 @@ client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; ``` @@ -40,6 +41,7 @@ client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; let users = new sdk.Users(client); diff --git a/docs/sdks/php/GETTING_STARTED.md b/docs/sdks/php/GETTING_STARTED.md index b92bb90e93..a7ceb61372 100644 --- a/docs/sdks/php/GETTING_STARTED.md +++ b/docs/sdks/php/GETTING_STARTED.md @@ -10,6 +10,7 @@ $client ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + ->setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; ``` @@ -33,6 +34,7 @@ $client ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key + ->setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; $users = new Users($client); diff --git a/docs/sdks/python/GETTING_STARTED.md b/docs/sdks/python/GETTING_STARTED.md index b513f01da8..81c7954509 100644 --- a/docs/sdks/python/GETTING_STARTED.md +++ b/docs/sdks/python/GETTING_STARTED.md @@ -13,6 +13,7 @@ client = Client() .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint .set_project('5df5acd0d48c2') # Your project ID .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key + .set_self_signed() # Use only on dev mode with a self-signed SSL cert ) ``` @@ -36,6 +37,7 @@ client = Client() .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint .set_project('5df5acd0d48c2') # Your project ID .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key + .set_self_signed() # Use only on dev mode with a self-signed SSL cert ) users = Users(client) diff --git a/docs/sdks/ruby/GETTING_STARTED.md b/docs/sdks/ruby/GETTING_STARTED.md index 23de47c1a3..acabf1c0a9 100644 --- a/docs/sdks/ruby/GETTING_STARTED.md +++ b/docs/sdks/ruby/GETTING_STARTED.md @@ -12,6 +12,7 @@ client .set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint .set_project(ENV["APPWRITE_PROJECT"]) # Your project ID .set_key(ENV["APPWRITE_SECRET"]) # Your secret API key + .setSelfSigned() # Use only on dev mode with a self-signed SSL cert ; ``` @@ -34,6 +35,7 @@ client .set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint .set_project(ENV["APPWRITE_PROJECT"]) # Your project ID .set_key(ENV["APPWRITE_SECRET"]) # Your secret API key + .setSelfSigned() # Use only on dev mode with a self-signed SSL cert ; users = Appwrite::Users.new(client); diff --git a/docs/sdks/web/GETTING_STARTED.md b/docs/sdks/web/GETTING_STARTED.md index c8eee4999b..f8908ae9d3 100644 --- a/docs/sdks/web/GETTING_STARTED.md +++ b/docs/sdks/web/GETTING_STARTED.md @@ -15,6 +15,7 @@ const appwrite = new Appwrite(); appwrite .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint .setProject('455x34dfkj') // Your project ID + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; ``` @@ -41,6 +42,7 @@ const appwrite = new Appwrite(); appwrite .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint .setProject('455x34dfkj') + .setSelfSigned() // Use only on dev mode with a self-signed SSL cert ; // Register User From 5d0ea6a45f3c66f2aca137e67bad364a310f00de Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 1 Apr 2021 11:59:23 +0545 Subject: [PATCH 13/34] Set default locale on .env #1052 --- .env | 1 + app/init.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 581af6d978..6e3367a7e5 100644 --- a/.env +++ b/.env @@ -1,5 +1,6 @@ _APP_ENV=production _APP_ENV=development +_APP_LOCALE=en _APP_SYSTEM_EMAIL_NAME=Appwrite _APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io _APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io diff --git a/app/init.php b/app/init.php index 2aa5fb0206..311cfccb61 100644 --- a/app/init.php +++ b/app/init.php @@ -313,7 +313,7 @@ App::setResource('layout', function($locale) { }, ['locale']); App::setResource('locale', function() { - return new Locale('en'); + return new Locale(App::getEnv('_APP_LOCALE', 'en')); }); // Queues From ae2cc4481719cd3c8db442c9558593482be6143e Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 3 Apr 2021 09:29:13 +0300 Subject: [PATCH 14/34] First commit --- CHANGES.md | 1 + app/views/console/database/collection.phtml | 9 +- app/views/console/database/index.phtml | 71 ++++++----- app/views/console/storage/index.phtml | 86 ++++++------- app/views/console/users/index.phtml | 134 ++++++++++---------- 5 files changed, 152 insertions(+), 149 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index bafda3313b..c8f9500782 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ - Added events for functions and executions (#971) - Splited token & session models to become 2 different internal entities (#922) - Added Dart 2.12 as a new Cloud Functions runtime (#989) +- Updated all the console bottom control to be consistent. Dropped the `+` icon ## Bugs - Fixed default value for HTTPS force option diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index 45d3287cf5..f10e97e1fa 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -36,9 +36,6 @@ $maxCells = 10;
  • - - -

    Documents

    @@ -135,7 +132,7 @@ $maxCells = 10;
-
  • diff --git a/app/views/console/database/index.phtml b/app/views/console/database/index.phtml index 8ec46a13ad..2760a1ac10 100644 --- a/app/views/console/database/index.phtml +++ b/app/views/console/database/index.phtml @@ -12,40 +12,6 @@
  • Collections

    - -
    -
    +
    + + +