1
0
Fork 0
mirror of synced 2024-06-19 03:04:53 +12:00

Added project ID validation

This commit is contained in:
eldadfux 2019-11-29 20:26:06 +02:00
parent f41cc152a3
commit 80fdf36016
15 changed files with 35 additions and 7 deletions

View file

@ -13,6 +13,8 @@ use Database\Validator\Authorization;
use DeviceDetector\DeviceDetector;
use GeoIp2\Database\Reader;
include_once 'shared/api.php';
$utopia->get('/v1/account')
->desc('Get Account')
->label('scope', 'account')

View file

@ -18,6 +18,8 @@ use Database\Validator\UID;
use Template\Template;
use OpenSSL\OpenSSL;
include_once 'shared/api.php';
$utopia->post('/v1/auth/register')
->desc('Register')
->label('webhook', 'auth.register')

View file

@ -15,6 +15,8 @@ use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
include_once 'shared/api.php';
$types = [
'browsers' => include __DIR__.'/../config/avatars/browsers.php',
'credit-cards' => include __DIR__.'/../config/avatars/credit-cards.php',

View file

@ -19,6 +19,8 @@ use Database\Validator\Authorization;
use Database\Exception\Authorization as AuthorizationException;
use Database\Exception\Structure as StructureException;
include_once 'shared/api.php';
$isDev = (App::ENV_TYPE_PRODUCTION !== $utopia->getEnv());
$utopia->get('/v1/database')

View file

@ -6,6 +6,8 @@ use Utopia\App;
use Utopia\Locale\Locale;
use GeoIp2\Database\Reader;
include_once 'shared/api.php';
$utopia->get('/v1/locale')
->desc('Get User Locale')
->label('scope', 'locale.read')

View file

@ -16,6 +16,8 @@ use Database\Validator\UID;
use OpenSSL\OpenSSL;
use Cron\CronExpression;
include_once 'shared/api.php';
$scopes = [ // TODO sync with console UI list
'users.read',
'users.write',

View file

@ -22,6 +22,8 @@ use Storage\Compression\Algorithms\GZIP;
use Resize\Resize;
use OpenSSL\OpenSSL;
include_once 'shared/api.php';
Storage::addDevice('local', new Local('app-'.$project->getUid()));
$fileLogos = [ // Based on this list @see http://stackoverflow.com/a/4212908/2299554

View file

@ -18,6 +18,8 @@ use Database\Validator\Authorization;
use Template\Template;
use Auth\Auth;
include_once 'shared/api.php';
$utopia->get('/v1/teams')
->desc('List Teams')
->label('scope', 'teams.read')

View file

@ -16,6 +16,8 @@ use Database\Validator\UID;
use DeviceDetector\DeviceDetector;
use GeoIp2\Database\Reader;
include_once 'shared/api.php';
$utopia->get('/v1/users')
->desc('List Users')
->label('scope', 'users.read')

View file

@ -212,10 +212,6 @@ Authorization::enable();
$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'));
Auth::setCookieName('a_session_'.$project->getUid());

View file

@ -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/
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/

View file

@ -37,6 +37,7 @@ class BaseConsole extends TestCase
$response = $this->client->call(Client::METHOD_POST, '/auth/register', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => 'console',
], [
'email' => $this->demoEmail,
'password' => $this->demoPassword,
@ -45,7 +46,7 @@ class BaseConsole extends TestCase
'failure' => 'http://localhost/failure',
'name' => 'Demo User',
]);
return $response;
}
@ -61,6 +62,7 @@ class BaseConsole extends TestCase
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $session,
'x-appwrite-project' => 'console',
], [
'name' => 'Demo Project Team',
]);
@ -73,6 +75,7 @@ class BaseConsole extends TestCase
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $session,
'x-appwrite-project' => 'console',
], [
'name' => 'Demo Project',
'teamId' => $team['body']['$uid'],
@ -94,6 +97,7 @@ class BaseConsole extends TestCase
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $session,
'x-appwrite-project' => 'console',
], [
'name' => 'Demo Project Key',
'scopes' => $scopes,

View file

@ -31,6 +31,7 @@ class ConsoleProjectsTest extends BaseConsole
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $data['session'],
'x-appwrite-project' => 'console',
], []);
$this->assertEquals(200, $response['headers']['status-code']);
@ -46,6 +47,7 @@ class ConsoleProjectsTest extends BaseConsole
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $data['session'],
'x-appwrite-project' => 'console',
], [
'name' => 'Demo Project Team',
]);
@ -58,6 +60,7 @@ class ConsoleProjectsTest extends BaseConsole
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $data['session'],
'x-appwrite-project' => 'console',
], [
'name' => 'Demo Project',
'teamId' => $team['body']['$uid'],
@ -89,6 +92,7 @@ class ConsoleProjectsTest extends BaseConsole
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $data['session'],
'x-appwrite-project' => 'console',
], array_merge($data['project'], [
'name' => 'New Project Name',
'description' => 'New Demo Project Description',

View file

@ -27,6 +27,7 @@ class ConsoleTest extends BaseConsole
$response = $this->client->call(Client::METHOD_POST, '/auth/login', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => 'console',
], [
'email' => $data['email'],
'password' => $data['password'],
@ -55,6 +56,7 @@ class ConsoleTest extends BaseConsole
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $data['session'],
'x-appwrite-project' => 'console',
], []);
$this->assertEquals('Demo User', $response['body']['name']);
@ -78,6 +80,7 @@ class ConsoleTest extends BaseConsole
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $data['session'],
'x-appwrite-project' => 'console',
], []);
$this->assertEquals(200, $response['headers']['status-code']);
@ -89,6 +92,7 @@ class ConsoleTest extends BaseConsole
$response = $this->client->call(Client::METHOD_DELETE, '/auth/logout', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => 'console',
], []);
$this->assertEquals('401', $response['body']['code']);

View file

@ -19,7 +19,6 @@ class ProjectLocaleTest extends BaseProjects
$locale = $this->client->call(Client::METHOD_GET, '/locale', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
//'x-appwrite-key' => $data['projectAPIKeySecret'],
]);
$this->assertArrayHasKey('ip', $locale['body']);
@ -52,6 +51,7 @@ class ProjectLocaleTest extends BaseProjects
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
'x-appwrite-locale' => 'es',
]);
@ -82,6 +82,7 @@ class ProjectLocaleTest extends BaseProjects
$countries = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
'x-appwrite-locale' => 'es',
]);
@ -111,6 +112,7 @@ class ProjectLocaleTest extends BaseProjects
// Test locale code change to ES
$continents = $this->client->call(Client::METHOD_GET, '/locale/continents', [
'content-type' => 'application/json',
'x-appwrite-project' => $data['projectUid'],
'x-appwrite-locale' => 'es',
]);