Added project ID validation
This commit is contained in:
parent
f41cc152a3
commit
80fdf36016
|
@ -13,6 +13,8 @@ use Database\Validator\Authorization;
|
||||||
use DeviceDetector\DeviceDetector;
|
use DeviceDetector\DeviceDetector;
|
||||||
use GeoIp2\Database\Reader;
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
include_once 'shared/api.php';
|
||||||
|
|
||||||
$utopia->get('/v1/account')
|
$utopia->get('/v1/account')
|
||||||
->desc('Get Account')
|
->desc('Get Account')
|
||||||
->label('scope', 'account')
|
->label('scope', 'account')
|
||||||
|
|
|
@ -18,6 +18,8 @@ use Database\Validator\UID;
|
||||||
use Template\Template;
|
use Template\Template;
|
||||||
use OpenSSL\OpenSSL;
|
use OpenSSL\OpenSSL;
|
||||||
|
|
||||||
|
include_once 'shared/api.php';
|
||||||
|
|
||||||
$utopia->post('/v1/auth/register')
|
$utopia->post('/v1/auth/register')
|
||||||
->desc('Register')
|
->desc('Register')
|
||||||
->label('webhook', 'auth.register')
|
->label('webhook', 'auth.register')
|
||||||
|
|
|
@ -15,6 +15,8 @@ use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
|
||||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||||
use BaconQrCode\Writer;
|
use BaconQrCode\Writer;
|
||||||
|
|
||||||
|
include_once 'shared/api.php';
|
||||||
|
|
||||||
$types = [
|
$types = [
|
||||||
'browsers' => include __DIR__.'/../config/avatars/browsers.php',
|
'browsers' => include __DIR__.'/../config/avatars/browsers.php',
|
||||||
'credit-cards' => include __DIR__.'/../config/avatars/credit-cards.php',
|
'credit-cards' => include __DIR__.'/../config/avatars/credit-cards.php',
|
||||||
|
|
|
@ -19,6 +19,8 @@ use Database\Validator\Authorization;
|
||||||
use Database\Exception\Authorization as AuthorizationException;
|
use Database\Exception\Authorization as AuthorizationException;
|
||||||
use Database\Exception\Structure as StructureException;
|
use Database\Exception\Structure as StructureException;
|
||||||
|
|
||||||
|
include_once 'shared/api.php';
|
||||||
|
|
||||||
$isDev = (App::ENV_TYPE_PRODUCTION !== $utopia->getEnv());
|
$isDev = (App::ENV_TYPE_PRODUCTION !== $utopia->getEnv());
|
||||||
|
|
||||||
$utopia->get('/v1/database')
|
$utopia->get('/v1/database')
|
||||||
|
|
|
@ -6,6 +6,8 @@ use Utopia\App;
|
||||||
use Utopia\Locale\Locale;
|
use Utopia\Locale\Locale;
|
||||||
use GeoIp2\Database\Reader;
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
include_once 'shared/api.php';
|
||||||
|
|
||||||
$utopia->get('/v1/locale')
|
$utopia->get('/v1/locale')
|
||||||
->desc('Get User Locale')
|
->desc('Get User Locale')
|
||||||
->label('scope', 'locale.read')
|
->label('scope', 'locale.read')
|
||||||
|
|
|
@ -16,6 +16,8 @@ use Database\Validator\UID;
|
||||||
use OpenSSL\OpenSSL;
|
use OpenSSL\OpenSSL;
|
||||||
use Cron\CronExpression;
|
use Cron\CronExpression;
|
||||||
|
|
||||||
|
include_once 'shared/api.php';
|
||||||
|
|
||||||
$scopes = [ // TODO sync with console UI list
|
$scopes = [ // TODO sync with console UI list
|
||||||
'users.read',
|
'users.read',
|
||||||
'users.write',
|
'users.write',
|
||||||
|
|
|
@ -22,6 +22,8 @@ use Storage\Compression\Algorithms\GZIP;
|
||||||
use Resize\Resize;
|
use Resize\Resize;
|
||||||
use OpenSSL\OpenSSL;
|
use OpenSSL\OpenSSL;
|
||||||
|
|
||||||
|
include_once 'shared/api.php';
|
||||||
|
|
||||||
Storage::addDevice('local', new Local('app-'.$project->getUid()));
|
Storage::addDevice('local', new Local('app-'.$project->getUid()));
|
||||||
|
|
||||||
$fileLogos = [ // Based on this list @see http://stackoverflow.com/a/4212908/2299554
|
$fileLogos = [ // Based on this list @see http://stackoverflow.com/a/4212908/2299554
|
||||||
|
|
|
@ -18,6 +18,8 @@ use Database\Validator\Authorization;
|
||||||
use Template\Template;
|
use Template\Template;
|
||||||
use Auth\Auth;
|
use Auth\Auth;
|
||||||
|
|
||||||
|
include_once 'shared/api.php';
|
||||||
|
|
||||||
$utopia->get('/v1/teams')
|
$utopia->get('/v1/teams')
|
||||||
->desc('List Teams')
|
->desc('List Teams')
|
||||||
->label('scope', 'teams.read')
|
->label('scope', 'teams.read')
|
||||||
|
|
|
@ -16,6 +16,8 @@ use Database\Validator\UID;
|
||||||
use DeviceDetector\DeviceDetector;
|
use DeviceDetector\DeviceDetector;
|
||||||
use GeoIp2\Database\Reader;
|
use GeoIp2\Database\Reader;
|
||||||
|
|
||||||
|
include_once 'shared/api.php';
|
||||||
|
|
||||||
$utopia->get('/v1/users')
|
$utopia->get('/v1/users')
|
||||||
->desc('List Users')
|
->desc('List Users')
|
||||||
->label('scope', 'users.read')
|
->label('scope', 'users.read')
|
||||||
|
|
|
@ -212,10 +212,6 @@ Authorization::enable();
|
||||||
|
|
||||||
$console = $consoleDB->getDocument('console');
|
$console = $consoleDB->getDocument('console');
|
||||||
|
|
||||||
if (is_null($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) {
|
|
||||||
$project = $console;
|
|
||||||
}
|
|
||||||
|
|
||||||
$mode = $request->getParam('mode', $request->getHeader('X-Appwrite-Mode', 'default'));
|
$mode = $request->getParam('mode', $request->getHeader('X-Appwrite-Mode', 'default'));
|
||||||
|
|
||||||
Auth::setCookieName('a_session_'.$project->getUid());
|
Auth::setCookieName('a_session_'.$project->getUid());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by pub on 2019-11-29 09:30:15.272008.
|
# Generated by pub on 2019-11-29 19:32:31.271463.
|
||||||
charcode:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
|
charcode:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
|
||||||
collection:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/collection-1.14.12/lib/
|
collection:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/collection-1.14.12/lib/
|
||||||
cookie_jar:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/cookie_jar-1.0.1/lib/
|
cookie_jar:file:///Users/eldadfux/.pub-cache/hosted/pub.dartlang.org/cookie_jar-1.0.1/lib/
|
||||||
|
|
|
@ -37,6 +37,7 @@ class BaseConsole extends TestCase
|
||||||
$response = $this->client->call(Client::METHOD_POST, '/auth/register', [
|
$response = $this->client->call(Client::METHOD_POST, '/auth/register', [
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], [
|
], [
|
||||||
'email' => $this->demoEmail,
|
'email' => $this->demoEmail,
|
||||||
'password' => $this->demoPassword,
|
'password' => $this->demoPassword,
|
||||||
|
@ -45,7 +46,7 @@ class BaseConsole extends TestCase
|
||||||
'failure' => 'http://localhost/failure',
|
'failure' => 'http://localhost/failure',
|
||||||
'name' => 'Demo User',
|
'name' => 'Demo User',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ class BaseConsole extends TestCase
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'cookie' => 'a_session_console=' . $session,
|
'cookie' => 'a_session_console=' . $session,
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], [
|
], [
|
||||||
'name' => 'Demo Project Team',
|
'name' => 'Demo Project Team',
|
||||||
]);
|
]);
|
||||||
|
@ -73,6 +75,7 @@ class BaseConsole extends TestCase
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'cookie' => 'a_session_console=' . $session,
|
'cookie' => 'a_session_console=' . $session,
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], [
|
], [
|
||||||
'name' => 'Demo Project',
|
'name' => 'Demo Project',
|
||||||
'teamId' => $team['body']['$uid'],
|
'teamId' => $team['body']['$uid'],
|
||||||
|
@ -94,6 +97,7 @@ class BaseConsole extends TestCase
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'cookie' => 'a_session_console=' . $session,
|
'cookie' => 'a_session_console=' . $session,
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], [
|
], [
|
||||||
'name' => 'Demo Project Key',
|
'name' => 'Demo Project Key',
|
||||||
'scopes' => $scopes,
|
'scopes' => $scopes,
|
||||||
|
|
|
@ -31,6 +31,7 @@ class ConsoleProjectsTest extends BaseConsole
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'cookie' => 'a_session_console=' . $data['session'],
|
'cookie' => 'a_session_console=' . $data['session'],
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], []);
|
], []);
|
||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
|
@ -46,6 +47,7 @@ class ConsoleProjectsTest extends BaseConsole
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'cookie' => 'a_session_console=' . $data['session'],
|
'cookie' => 'a_session_console=' . $data['session'],
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], [
|
], [
|
||||||
'name' => 'Demo Project Team',
|
'name' => 'Demo Project Team',
|
||||||
]);
|
]);
|
||||||
|
@ -58,6 +60,7 @@ class ConsoleProjectsTest extends BaseConsole
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'cookie' => 'a_session_console=' . $data['session'],
|
'cookie' => 'a_session_console=' . $data['session'],
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], [
|
], [
|
||||||
'name' => 'Demo Project',
|
'name' => 'Demo Project',
|
||||||
'teamId' => $team['body']['$uid'],
|
'teamId' => $team['body']['$uid'],
|
||||||
|
@ -89,6 +92,7 @@ class ConsoleProjectsTest extends BaseConsole
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'cookie' => 'a_session_console=' . $data['session'],
|
'cookie' => 'a_session_console=' . $data['session'],
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], array_merge($data['project'], [
|
], array_merge($data['project'], [
|
||||||
'name' => 'New Project Name',
|
'name' => 'New Project Name',
|
||||||
'description' => 'New Demo Project Description',
|
'description' => 'New Demo Project Description',
|
||||||
|
|
|
@ -27,6 +27,7 @@ class ConsoleTest extends BaseConsole
|
||||||
$response = $this->client->call(Client::METHOD_POST, '/auth/login', [
|
$response = $this->client->call(Client::METHOD_POST, '/auth/login', [
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], [
|
], [
|
||||||
'email' => $data['email'],
|
'email' => $data['email'],
|
||||||
'password' => $data['password'],
|
'password' => $data['password'],
|
||||||
|
@ -55,6 +56,7 @@ class ConsoleTest extends BaseConsole
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'cookie' => 'a_session_console=' . $data['session'],
|
'cookie' => 'a_session_console=' . $data['session'],
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], []);
|
], []);
|
||||||
|
|
||||||
$this->assertEquals('Demo User', $response['body']['name']);
|
$this->assertEquals('Demo User', $response['body']['name']);
|
||||||
|
@ -78,6 +80,7 @@ class ConsoleTest extends BaseConsole
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'cookie' => 'a_session_console=' . $data['session'],
|
'cookie' => 'a_session_console=' . $data['session'],
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], []);
|
], []);
|
||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
|
@ -89,6 +92,7 @@ class ConsoleTest extends BaseConsole
|
||||||
$response = $this->client->call(Client::METHOD_DELETE, '/auth/logout', [
|
$response = $this->client->call(Client::METHOD_DELETE, '/auth/logout', [
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => 'console',
|
||||||
], []);
|
], []);
|
||||||
|
|
||||||
$this->assertEquals('401', $response['body']['code']);
|
$this->assertEquals('401', $response['body']['code']);
|
||||||
|
|
|
@ -19,7 +19,6 @@ class ProjectLocaleTest extends BaseProjects
|
||||||
$locale = $this->client->call(Client::METHOD_GET, '/locale', [
|
$locale = $this->client->call(Client::METHOD_GET, '/locale', [
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'x-appwrite-project' => $data['projectUid'],
|
'x-appwrite-project' => $data['projectUid'],
|
||||||
//'x-appwrite-key' => $data['projectAPIKeySecret'],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertArrayHasKey('ip', $locale['body']);
|
$this->assertArrayHasKey('ip', $locale['body']);
|
||||||
|
@ -52,6 +51,7 @@ class ProjectLocaleTest extends BaseProjects
|
||||||
|
|
||||||
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $data['projectUid'],
|
||||||
'x-appwrite-locale' => 'es',
|
'x-appwrite-locale' => 'es',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ class ProjectLocaleTest extends BaseProjects
|
||||||
|
|
||||||
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
|
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $data['projectUid'],
|
||||||
'x-appwrite-locale' => 'es',
|
'x-appwrite-locale' => 'es',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -111,6 +112,7 @@ class ProjectLocaleTest extends BaseProjects
|
||||||
// Test locale code change to ES
|
// Test locale code change to ES
|
||||||
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $data['projectUid'],
|
||||||
'x-appwrite-locale' => 'es',
|
'x-appwrite-locale' => 'es',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue