1
0
Fork 0
mirror of synced 2024-09-29 08:51:28 +13:00

Merge branch 'feat-265-realtime' of https://github.com/appwrite/appwrite into feat-265-realtime-console

This commit is contained in:
Torsten Dittmann 2021-08-18 12:51:31 +02:00
commit bf6e5b72a2
2 changed files with 11 additions and 11 deletions

View file

@ -33,7 +33,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB
/** @var Utopia\Locale\Locale $locale */ /** @var Utopia\Locale\Locale $locale */
/** @var bool $mode */ /** @var bool $mode */
/** @var array $clients */ /** @var array $clients */
$domain = $request->getHostname(); $domain = $request->getHostname();
$domains = Config::getParam('domains', []); $domains = Config::getParam('domains', []);
if (!array_key_exists($domain, $domains)) { if (!array_key_exists($domain, $domains)) {
@ -98,7 +98,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB
$refDomain = (!empty($protocol) ? $protocol : $request->getProtocol()).'://'.((\in_array($origin, $clients)) $refDomain = (!empty($protocol) ? $protocol : $request->getProtocol()).'://'.((\in_array($origin, $clients))
? $origin : 'localhost').(!empty($port) ? ':'.$port : ''); ? $origin : 'localhost').(!empty($port) ? ':'.$port : '');
$refDomain = (!$route->getLabel('origin', false)) // This route is publicly accessible $refDomain = (!$route->getLabel('origin', false)) // This route is publicly accessible
? $refDomain ? $refDomain
: (!empty($protocol) ? $protocol : $request->getProtocol()).'://'.$origin.(!empty($port) ? ':'.$port : ''); : (!empty($protocol) ? $protocol : $request->getProtocol()).'://'.$origin.(!empty($port) ? ':'.$port : '');
@ -119,7 +119,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB
Config::setParam('domainVerification', Config::setParam('domainVerification',
($selfDomain->getRegisterable() === $endDomain->getRegisterable()) && ($selfDomain->getRegisterable() === $endDomain->getRegisterable()) &&
$endDomain->getRegisterable() !== ''); $endDomain->getRegisterable() !== '');
Config::setParam('cookieDomain', ( Config::setParam('cookieDomain', (
$request->getHostname() === 'localhost' || $request->getHostname() === 'localhost' ||
$request->getHostname() === 'localhost:'.$request->getPort() || $request->getHostname() === 'localhost:'.$request->getPort() ||
@ -189,7 +189,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB
&& empty($request->getHeader('x-appwrite-key', ''))) { && empty($request->getHeader('x-appwrite-key', ''))) {
throw new Exception($originValidator->getDescription(), 403); throw new Exception($originValidator->getDescription(), 403);
} }
/* /*
* ACL Check * ACL Check
*/ */
@ -223,7 +223,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB
if (!empty($authKey)) { // API Key authentication if (!empty($authKey)) { // API Key authentication
// Check if given key match project API keys // Check if given key match project API keys
$key = $project->search('secret', $authKey, $project->getAttribute('keys', [])); $key = $project->search('secret', $authKey, $project->getAttribute('keys', []));
/* /*
* Try app auth when we have project key and no user * Try app auth when we have project key and no user
* Mock user to app and grant API key scopes in addition to default app scopes * Mock user to app and grant API key scopes in addition to default app scopes
@ -245,8 +245,8 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB
} }
} }
foreach (Auth::getRoles($user) as $role) { foreach (Auth::getRoles($user) as $authRole) {
Authorization::setRole($role); Authorization::setRole($authRole);
} }
// TDOO Check if user is root // TDOO Check if user is root
@ -255,7 +255,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) { // Check if permission is denied because project is missing if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) { // Check if permission is denied because project is missing
throw new Exception('Project not found', 404); throw new Exception('Project not found', 404);
} }
throw new Exception($user->getAttribute('email', 'User').' (role: '.\strtolower($roles[$role]['label']).') missing scope ('.$scope.')', 401); throw new Exception($user->getAttribute('email', 'User').' (role: '.\strtolower($roles[$role]['label']).') missing scope ('.$scope.')', 401);
} }
@ -302,12 +302,12 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) {
if (php_sapi_name() === 'cli') { if (php_sapi_name() === 'cli') {
Console::error('[Error] Timestamp: '.date('c', time())); Console::error('[Error] Timestamp: '.date('c', time()));
if($route) { if($route) {
Console::error('[Error] Method: '.$route->getMethod()); Console::error('[Error] Method: '.$route->getMethod());
Console::error('[Error] URL: '.$route->getURL()); Console::error('[Error] URL: '.$route->getURL());
} }
Console::error('[Error] Type: '.get_class($error)); Console::error('[Error] Type: '.get_class($error));
Console::error('[Error] Message: '.$error->getMessage()); Console::error('[Error] Message: '.$error->getMessage());
Console::error('[Error] File: '.$error->getFile()); Console::error('[Error] File: '.$error->getFile());

View file

@ -632,7 +632,7 @@ trait RealtimeBase
'x-appwrite-key' => $this->getProject()['apiKey'] 'x-appwrite-key' => $this->getProject()['apiKey']
]), [ ]), [
'name' => 'Test', 'name' => 'Test',
'runtime' => 'php-7.4', 'runtime' => 'php-8.0',
'execute' => ['*'], 'execute' => ['*'],
'timeout' => 10, 'timeout' => 10,
]); ]);