Updated PHP coding standards
This commit is contained in:
parent
d80c6479d3
commit
c706349c10
203
app/app.php
203
app/app.php
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
// Init
|
||||
require_once __DIR__ . '/init.php';
|
||||
require_once __DIR__.'/init.php';
|
||||
|
||||
global $env, $utopia, $request, $response, $register, $consoleDB, $project, $domain, $sentry, $version, $service, $providers;
|
||||
|
||||
|
@ -20,16 +20,16 @@ use Database\Validator\Authorization;
|
|||
use Event\Event;
|
||||
use Utopia\Validator\WhiteList;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Configuration files
|
||||
*/
|
||||
$roles = include __DIR__ . '/config/roles.php'; // User roles and scopes
|
||||
$sdks = include __DIR__ . '/config/sdks.php'; // List of SDK clients
|
||||
$services = include __DIR__ . '/config/services.php'; // List of SDK clients
|
||||
$roles = include __DIR__.'/config/roles.php'; // User roles and scopes
|
||||
$sdks = include __DIR__.'/config/sdks.php'; // List of SDK clients
|
||||
$services = include __DIR__.'/config/services.php'; // List of SDK clients
|
||||
|
||||
$webhook = new Event('v1-webhooks', 'WebhooksV1');
|
||||
$audit = new Event('v1-audits', 'AuditsV1');
|
||||
$usage = new Event('v1-usage', 'UsageV1');
|
||||
$webhook = new Event('v1-webhooks', 'WebhooksV1');
|
||||
$audit = new Event('v1-audits', 'AuditsV1');
|
||||
$usage = new Event('v1-usage', 'UsageV1');
|
||||
|
||||
$clientsConsole = array_map(function ($node) {
|
||||
return $node['url'];
|
||||
|
@ -37,6 +37,7 @@ $clientsConsole = array_map(function ($node) {
|
|||
if (isset($node['type']) && $node['type'] === 'web' && isset($node['url']) && !empty($node['url'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}));
|
||||
|
||||
|
@ -46,19 +47,20 @@ $clients = array_merge($clientsConsole, array_map(function ($node) {
|
|||
if (isset($node['type']) && $node['type'] === 'web' && isset($node['url']) && !empty($node['url'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})));
|
||||
|
||||
$utopia->init(function () use ($utopia, $request, $response, $register, &$user, $project, $roles, $webhook, $audit, $usage, $domain, $clients) {
|
||||
$route = $utopia->match($request);
|
||||
|
||||
$referrer = $request->getServer('HTTP_REFERER', '');
|
||||
$origin = $request->getServer('HTTP_ORIGIN', parse_url($referrer, PHP_URL_SCHEME) . '://' . parse_url($referrer, PHP_URL_HOST));
|
||||
$referrer = $request->getServer('HTTP_REFERER', '');
|
||||
$origin = $request->getServer('HTTP_ORIGIN', parse_url($referrer, PHP_URL_SCHEME).'://'.parse_url($referrer, PHP_URL_HOST));
|
||||
|
||||
$refDomain = (in_array($origin, $clients))
|
||||
? $origin : 'http://localhost';
|
||||
|
||||
/**
|
||||
/*
|
||||
* Security Headers
|
||||
*
|
||||
* As recommended at:
|
||||
|
@ -66,7 +68,7 @@ $utopia->init(function () use ($utopia, $request, $response, $register, &$user,
|
|||
*/
|
||||
$response
|
||||
->addHeader('Server', 'Appwrite')
|
||||
->addHeader('X-XSS-Protection', '1; mode=block; report=/v1/xss?url=' . urlencode($request->getServer('REQUEST_URI')))
|
||||
->addHeader('X-XSS-Protection', '1; mode=block; report=/v1/xss?url='.urlencode($request->getServer('REQUEST_URI')))
|
||||
//->addHeader('X-Frame-Options', ($refDomain == 'http://localhost') ? 'SAMEORIGIN' : 'ALLOW-FROM ' . $refDomain)
|
||||
->addHeader('X-Content-Type-Options', 'nosniff')
|
||||
->addHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE')
|
||||
|
@ -75,7 +77,7 @@ $utopia->init(function () use ($utopia, $request, $response, $register, &$user,
|
|||
->addHeader('Access-Control-Allow-Credentials', 'true')
|
||||
;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Validate Client Domain - Check to avoid CSRF attack
|
||||
* Adding appwrite api domains to allow XDOMAIN communication
|
||||
*/
|
||||
|
@ -84,10 +86,10 @@ $utopia->init(function () use ($utopia, $request, $response, $register, &$user,
|
|||
if (!$hostValidator->isValid($request->getServer('HTTP_ORIGIN', $request->getServer('HTTP_REFERER', '')))
|
||||
&& in_array($request->getMethod(), [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE])
|
||||
&& empty($request->getHeader('X-Appwrite-Key', ''))) {
|
||||
throw new Exception('Access from this client host is forbidden. ' . $hostValidator->getDescription(), 403);
|
||||
throw new Exception('Access from this client host is forbidden. '.$hostValidator->getDescription(), 403);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* ACL Check
|
||||
*/
|
||||
$role = ($user->isEmpty()) ? Auth::USER_ROLE_GUEST : Auth::USER_ROLE_MEMBER;
|
||||
|
@ -111,46 +113,46 @@ $utopia->init(function () use ($utopia, $request, $response, $register, &$user,
|
|||
}
|
||||
}
|
||||
|
||||
$scope = $route->getLabel('scope', 'none'); // Allowed scope for chosen route
|
||||
$scopes = $roles[$role]['scopes']; // Allowed scopes for user role
|
||||
$scope = $route->getLabel('scope', 'none'); // Allowed scope for chosen route
|
||||
$scopes = $roles[$role]['scopes']; // Allowed scopes for user role
|
||||
|
||||
// Check if given key match project API keys
|
||||
$key = $project->search('secret', $request->getHeader('X-Appwrite-Key', ''), $project->getAttribute('keys', []));
|
||||
|
||||
/**
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
if (null !== $key && $user->isEmpty()) {
|
||||
$user = new Document([
|
||||
'$uid' => 0,
|
||||
'status' => Auth::USER_STATUS_ACTIVATED,
|
||||
'email' => 'app.' . $project->getUid() . '@service.' . $domain,
|
||||
'password' => '',
|
||||
'name' => $project->getAttribute('name', 'Untitled'),
|
||||
'$uid' => 0,
|
||||
'status' => Auth::USER_STATUS_ACTIVATED,
|
||||
'email' => 'app.'.$project->getUid().'@service.'.$domain,
|
||||
'password' => '',
|
||||
'name' => $project->getAttribute('name', 'Untitled'),
|
||||
]);
|
||||
|
||||
$role = Auth::USER_ROLE_APP;
|
||||
$role = Auth::USER_ROLE_APP;
|
||||
$scopes = array_merge($roles[$role]['scopes'], $key->getAttribute('scopes', []));
|
||||
|
||||
Authorization::disable(); // Cancel security segmentation for API keys.
|
||||
}
|
||||
|
||||
Authorization::setRole('user:' . $user->getUid());
|
||||
Authorization::setRole('role:' . $role);
|
||||
Authorization::setRole('user:'.$user->getUid());
|
||||
Authorization::setRole('role:'.$role);
|
||||
|
||||
array_map(function ($node) {
|
||||
if (isset($node['teamId']) && isset($node['roles'])) {
|
||||
Authorization::setRole('team:' . $node['teamId']);
|
||||
Authorization::setRole('team:'.$node['teamId']);
|
||||
|
||||
foreach ($node['roles'] as $nodeRole) { // Set all team roles
|
||||
Authorization::setRole('team:' . $node['teamId'] . '/' . $nodeRole);
|
||||
Authorization::setRole('team:'.$node['teamId'].'/'.$nodeRole);
|
||||
}
|
||||
}
|
||||
}, $user->getAttribute('memberships', []));
|
||||
|
||||
if (!in_array($scope, $scopes)) {
|
||||
throw new Exception($user->getAttribute('email', 'Guest') . ' (role: ' . strtolower($roles[$role]['label']) . ') missing scope (' . $scope . ')', 401);
|
||||
throw new Exception($user->getAttribute('email', 'Guest').' (role: '.strtolower($roles[$role]['label']).') missing scope ('.$scope.')', 401);
|
||||
}
|
||||
|
||||
if (Auth::USER_STATUS_BLOCKED == $user->getAttribute('status')) { // Account has not been activated
|
||||
|
@ -161,7 +163,7 @@ $utopia->init(function () use ($utopia, $request, $response, $register, &$user,
|
|||
throw new Exception('Password reset is required', 412);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Background Jobs
|
||||
*/
|
||||
$webhook
|
||||
|
@ -182,31 +184,31 @@ $utopia->init(function () use ($utopia, $request, $response, $register, &$user,
|
|||
|
||||
$usage
|
||||
->setParam('projectId', $project->getUid())
|
||||
->setParam('url', $request->getServer('HTTP_HOST', '') . $request->getServer('REQUEST_URI', ''))
|
||||
->setParam('url', $request->getServer('HTTP_HOST', '').$request->getServer('REQUEST_URI', ''))
|
||||
->setParam('method', $request->getServer('REQUEST_METHOD', 'UNKNOWN'))
|
||||
->setParam('request', 0)
|
||||
->setParam('response', 0)
|
||||
->setParam('storage', 0)
|
||||
;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Abuse Check
|
||||
*/
|
||||
$timeLimit = new TimeLimit($route->getLabel('abuse-key', 'url:{url},ip:{ip}'), $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600), function () use ($register) {
|
||||
return $register->get('db');
|
||||
});
|
||||
$timeLimit->setNamespace('app_' . $project->getUid());
|
||||
$timeLimit->setNamespace('app_'.$project->getUid());
|
||||
$timeLimit
|
||||
->setParam('{userId}', $user->getUid())
|
||||
->setParam('{userAgent}', $request->getServer('HTTP_USER_AGENT', ''))
|
||||
->setParam('{ip}', $request->getIP())
|
||||
->setParam('{url}', $request->getServer('HTTP_HOST', '') . $route->getURL())
|
||||
->setParam('{url}', $request->getServer('HTTP_HOST', '').$route->getURL())
|
||||
;
|
||||
|
||||
//TODO make sure we get array here
|
||||
|
||||
foreach ($request->getParams() as $key => $value) { // Set request params as potential abuse keys
|
||||
$timeLimit->setParam('{param-' . $key . '}', (is_array($value)) ? json_encode($value) : $value);
|
||||
$timeLimit->setParam('{param-'.$key.'}', (is_array($value)) ? json_encode($value) : $value);
|
||||
}
|
||||
|
||||
$abuse = new Abuse($timeLimit);
|
||||
|
@ -218,7 +220,7 @@ $utopia->init(function () use ($utopia, $request, $response, $register, &$user,
|
|||
->addHeader('X-RateLimit-Reset', $timeLimit->time() + $route->getLabel('abuse-time', 3600))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
if ($abuse->check() && $request->getServer('_APP_OPTIONS_ABUSE', 'enabled') !== 'disabled') {
|
||||
throw new Exception('Too many requests', 429);
|
||||
}
|
||||
|
@ -226,7 +228,7 @@ $utopia->init(function () use ($utopia, $request, $response, $register, &$user,
|
|||
|
||||
$utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage) {
|
||||
|
||||
/**
|
||||
/*
|
||||
* Trigger Events for background jobs
|
||||
*/
|
||||
if (!empty($webhook->getParam('event'))) {
|
||||
|
@ -253,7 +255,6 @@ $utopia->options(function () use ($request, $response, $domain, $project) {
|
|||
->addHeader('Access-Control-Allow-Origin', $origin)
|
||||
->addHeader('Access-Control-Allow-Credentials', 'true')
|
||||
->send();
|
||||
;
|
||||
});
|
||||
|
||||
$utopia->error(function ($error /* @var $error Exception */) use ($request, $response, $utopia, $project, $env, $version, $sentry, $user) {
|
||||
|
@ -265,27 +266,27 @@ $utopia->error(function ($error /* @var $error Exception */) use ($request, $res
|
|||
case 404: // Error allowed publicly
|
||||
case 412: // Error allowed publicly
|
||||
case 429: // Error allowed publicly
|
||||
$code = $error->getCode();
|
||||
$message = $error->getMessage();
|
||||
$code = $error->getCode();
|
||||
$message = $error->getMessage();
|
||||
break;
|
||||
default:
|
||||
$code = 500; // All other errors get the generic 500 server error status code
|
||||
$message = 'Server Error';
|
||||
$code = 500; // All other errors get the generic 500 server error status code
|
||||
$message = 'Server Error';
|
||||
}
|
||||
|
||||
$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised
|
||||
|
||||
$output = ((App::ENV_TYPE_DEVELOPMENT == $env)) ? [
|
||||
'message' => $error->getMessage(),
|
||||
'code' => $error->getCode(),
|
||||
'file' => $error->getFile(),
|
||||
'line' => $error->getLine(),
|
||||
'trace' => $error->getTrace(),
|
||||
'version' => $version,
|
||||
'message' => $error->getMessage(),
|
||||
'code' => $error->getCode(),
|
||||
'file' => $error->getFile(),
|
||||
'line' => $error->getLine(),
|
||||
'trace' => $error->getTrace(),
|
||||
'version' => $version,
|
||||
] : [
|
||||
'message' => $message,
|
||||
'code' => $code,
|
||||
'version' => $version,
|
||||
'code' => $code,
|
||||
'version' => $version,
|
||||
];
|
||||
|
||||
$response
|
||||
|
@ -295,12 +296,12 @@ $utopia->error(function ($error /* @var $error Exception */) use ($request, $res
|
|||
->setStatusCode($code)
|
||||
;
|
||||
|
||||
$route = $utopia->match($request);
|
||||
$template = ($route) ? $route->getLabel('error', null): null;
|
||||
$route = $utopia->match($request);
|
||||
$template = ($route) ? $route->getLabel('error', null) : null;
|
||||
|
||||
if ($template) {
|
||||
$layout = new View(__DIR__ . '/views/layouts/default.phtml');
|
||||
$comp = new View($template);
|
||||
$layout = new View(__DIR__.'/views/layouts/default.phtml');
|
||||
$comp = new View($template);
|
||||
|
||||
$comp
|
||||
->setParam('projectName', $project->getAttribute('name'))
|
||||
|
@ -310,7 +311,7 @@ $utopia->error(function ($error /* @var $error Exception */) use ($request, $res
|
|||
;
|
||||
|
||||
$layout
|
||||
->setParam('title', $project->getAttribute('name') . ' - Error')
|
||||
->setParam('title', $project->getAttribute('name').' - Error')
|
||||
->setParam('description', 'No Description')
|
||||
->setParam('body', $comp)
|
||||
->setParam('version', $version)
|
||||
|
@ -344,9 +345,9 @@ $utopia->get('/manifest.json')
|
|||
[
|
||||
'src' => 'images/favicon.png',
|
||||
'sizes' => '256x256',
|
||||
'type' => 'image/png'
|
||||
]
|
||||
]
|
||||
'type' => 'image/png',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
);
|
||||
|
@ -357,10 +358,10 @@ $utopia->get('/robots.txt')
|
|||
->label('docs', false)
|
||||
->action(
|
||||
function () use ($response) {
|
||||
$response->text("# robotstxt.org/
|
||||
$response->text('# robotstxt.org/
|
||||
|
||||
User-agent: *
|
||||
");
|
||||
');
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -370,14 +371,14 @@ $utopia->get('/humans.txt')
|
|||
->label('docs', false)
|
||||
->action(
|
||||
function () use ($response) {
|
||||
$response->text("# humanstxt.org/
|
||||
$response->text('# humanstxt.org/
|
||||
# The humans responsible & technology colophon
|
||||
|
||||
# TEAM
|
||||
<name> -- <role> -- <twitter>
|
||||
|
||||
# THANKS
|
||||
<name>");
|
||||
<name>');
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -387,15 +388,15 @@ $utopia->get('/v1/info') // This is only visible to gods
|
|||
->action(
|
||||
function () use ($response, $user, $project, $version, $env) { //TODO CONSIDER BLOCKING THIS ACTION TO ROLE GOD
|
||||
$response->json([
|
||||
'name' => 'API',
|
||||
'version' => $version,
|
||||
'environment' => $env,
|
||||
'time' => date('Y-m-d H:i:s', time()),
|
||||
'user' => [
|
||||
'name' => 'API',
|
||||
'version' => $version,
|
||||
'environment' => $env,
|
||||
'time' => date('Y-m-d H:i:s', time()),
|
||||
'user' => [
|
||||
'id' => $user->getUid(),
|
||||
'name' => $user->getAttribute('name', ''),
|
||||
],
|
||||
'project' => [
|
||||
'project' => [
|
||||
'id' => $project->getUid(),
|
||||
'name' => $project->getAttribute('name', ''),
|
||||
],
|
||||
|
@ -418,7 +419,7 @@ $utopia->get('/v1/proxy')
|
|||
->label('docs', false)
|
||||
->action(
|
||||
function () use ($response, $console, $clients) {
|
||||
$view = new View(__DIR__ . '/views/proxy.phtml');
|
||||
$view = new View(__DIR__.'/views/proxy.phtml');
|
||||
$view
|
||||
->setParam('routes', '')
|
||||
->setParam('clients', array_merge($clients, $console->getAttribute('clients', [])))
|
||||
|
@ -449,6 +450,7 @@ $utopia->get('/v1/open-api-2.json')
|
|||
foreach ($ret as &$match) {
|
||||
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
|
||||
}
|
||||
|
||||
return implode('_', $ret);
|
||||
}
|
||||
|
||||
|
@ -457,7 +459,7 @@ $utopia->get('/v1/open-api-2.json')
|
|||
return str_replace([' ', '_'], '-', strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $input)));
|
||||
}
|
||||
|
||||
foreach ($services as $service) { /** @noinspection PhpIncludeInspection */
|
||||
foreach ($services as $service) { /* @noinspection PhpIncludeInspection */
|
||||
if (!$service['sdk']) {
|
||||
continue;
|
||||
}
|
||||
|
@ -471,7 +473,7 @@ $utopia->get('/v1/open-api-2.json')
|
|||
'server' => ['Project' => [], 'Key' => []],
|
||||
];
|
||||
|
||||
/**
|
||||
/*
|
||||
* Specifications (v3.0.0):
|
||||
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md
|
||||
*/
|
||||
|
@ -540,30 +542,23 @@ $utopia->get('/v1/open-api-2.json')
|
|||
],
|
||||
],
|
||||
],
|
||||
'Pets' =>
|
||||
array(
|
||||
'Pets' => array(
|
||||
'type' => 'array',
|
||||
'items' =>
|
||||
array(
|
||||
'items' => array(
|
||||
'$ref' => '#/definitions/Pet',
|
||||
),
|
||||
),
|
||||
'Error' =>
|
||||
array(
|
||||
'required' =>
|
||||
array(
|
||||
'Error' => array(
|
||||
'required' => array(
|
||||
0 => 'code',
|
||||
1 => 'message',
|
||||
),
|
||||
'properties' =>
|
||||
array(
|
||||
'code' =>
|
||||
array(
|
||||
'properties' => array(
|
||||
'code' => array(
|
||||
'type' => 'integer',
|
||||
'format' => 'int32',
|
||||
),
|
||||
'message' =>
|
||||
array(
|
||||
'message' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
|
@ -571,8 +566,8 @@ $utopia->get('/v1/open-api-2.json')
|
|||
],
|
||||
'externalDocs' => [
|
||||
'description' => 'Full API docs, specs and tutorials',
|
||||
'url' => $request->getServer('REQUEST_SCHEME', 'https') . '://' . $domain . '/docs'
|
||||
]
|
||||
'url' => $request->getServer('REQUEST_SCHEME', 'https').'://'.$domain.'/docs',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($utopia->getRoutes() as $key => $method) {
|
||||
|
@ -585,10 +580,10 @@ $utopia->get('/v1/open-api-2.json')
|
|||
continue;
|
||||
}
|
||||
|
||||
$url = str_replace('/v1', '', $route->getURL());
|
||||
$scope = $route->getLabel('scope', '');
|
||||
$hide = $route->getLabel('sdk.hide', false);
|
||||
$consumes = [];
|
||||
$url = str_replace('/v1', '', $route->getURL());
|
||||
$scope = $route->getLabel('scope', '');
|
||||
$hide = $route->getLabel('sdk.hide', false);
|
||||
$consumes = [];
|
||||
|
||||
if ($hide) {
|
||||
continue;
|
||||
|
@ -604,7 +599,7 @@ $utopia->get('/v1/open-api-2.json')
|
|||
200 => [
|
||||
'description' => 'An paged array of pets',
|
||||
'schema' => [
|
||||
'$ref' => '#/definitions/Pet'
|
||||
'$ref' => '#/definitions/Pet',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@ -615,7 +610,7 @@ $utopia->get('/v1/open-api-2.json')
|
|||
'weight' => $route->getOrder(),
|
||||
'cookies' => $route->getLabel('sdk.cookies', false),
|
||||
'location' => $route->getLabel('sdk.location', false),
|
||||
'demo' => 'docs/examples/' . fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')) . '/' . fromCamelCaseToDash($temp['operationId']) . '.md',
|
||||
'demo' => 'docs/examples/'.fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')).'/'.fromCamelCaseToDash($temp['operationId']).'.md',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -631,8 +626,8 @@ $utopia->get('/v1/open-api-2.json')
|
|||
'properties' => [],
|
||||
],
|
||||
'required' => [],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($route->getParams() as $name => $param) {
|
||||
|
@ -647,11 +642,11 @@ $utopia->get('/v1/open-api-2.json')
|
|||
switch ((!empty($validator)) ? get_class($validator) : '') {
|
||||
case 'Utopia\Validator\Text':
|
||||
$node['type'] = 'string';
|
||||
$node['x-example'] = '[' . strtoupper(fromCamelCase($node['name'])) . ']';
|
||||
$node['x-example'] = '['.strtoupper(fromCamelCase($node['name'])).']';
|
||||
break;
|
||||
case 'Database\Validator\UID':
|
||||
$node['type'] = 'string';
|
||||
$node['x-example'] = '[' . strtoupper(fromCamelCase($node['name'])) . ']';
|
||||
$node['x-example'] = '['.strtoupper(fromCamelCase($node['name'])).']';
|
||||
break;
|
||||
case 'Utopia\Validator\Email':
|
||||
$node['type'] = 'string';
|
||||
|
@ -678,7 +673,7 @@ $utopia->get('/v1/open-api-2.json')
|
|||
$node['type'] = 'array';
|
||||
$node['collectionFormat'] = 'multi';
|
||||
$node['items'] = [
|
||||
'type' => 'string'
|
||||
'type' => 'string',
|
||||
];
|
||||
break;
|
||||
case 'Auth\Validator\Password':
|
||||
|
@ -716,7 +711,7 @@ $utopia->get('/v1/open-api-2.json')
|
|||
$node['default'] = $param['default'];
|
||||
}
|
||||
|
||||
if (false !== strpos($url, ':' . $name)) { // Param is in URL path
|
||||
if (false !== strpos($url, ':'.$name)) { // Param is in URL path
|
||||
$node['in'] = 'path';
|
||||
$temp['parameters'][] = $node;
|
||||
} elseif ($key == 'GET') { // Param is in query
|
||||
|
@ -732,7 +727,7 @@ $utopia->get('/v1/open-api-2.json')
|
|||
}
|
||||
}
|
||||
|
||||
$url = str_replace(':' . $name, '{' . $name . '}', $url);
|
||||
$url = str_replace(':'.$name, '{'.$name.'}', $url);
|
||||
}
|
||||
|
||||
$temp['consumes'] = $consumes;
|
||||
|
@ -755,18 +750,18 @@ $name = APP_NAME;
|
|||
|
||||
if (array_key_exists($service, $services)) { /** @noinspection PhpIncludeInspection */
|
||||
include_once $services[$service]['controller'];
|
||||
$name = APP_NAME . ' ' . ucfirst($services[$service]['name']);
|
||||
$name = APP_NAME.' '.ucfirst($services[$service]['name']);
|
||||
} else {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include_once $services['/']['controller'];
|
||||
}
|
||||
|
||||
if (extension_loaded('newrelic')) {
|
||||
$route = $utopia->match($request);
|
||||
$url = (!empty($route)) ? $route->getURL() : '/error';
|
||||
$route = $utopia->match($request);
|
||||
$url = (!empty($route)) ? $route->getURL() : '/error';
|
||||
|
||||
newrelic_set_appname($name);
|
||||
newrelic_name_transaction($request->getServer('REQUEST_METHOD', 'UNKNOWN') . ': ' . $url);
|
||||
newrelic_name_transaction($request->getServer('REQUEST_METHOD', 'UNKNOWN').': '.$url);
|
||||
}
|
||||
|
||||
$utopia->run($request, $response);
|
||||
|
|
|
@ -38,13 +38,13 @@ $collections = [
|
|||
'$collection' => Database::SYSTEM_COLLECTION_PLATFORMS,
|
||||
'name' => 'Localhost (SSL)',
|
||||
'type' => 'web',
|
||||
'url' => 'https://' . $request->getServer('HTTP_HOST'),
|
||||
'url' => 'https://'.$request->getServer('HTTP_HOST'),
|
||||
],
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_PLATFORMS,
|
||||
'name' => 'Localhost (Non-SSL)',
|
||||
'type' => 'web',
|
||||
'url' => 'http://' . $request->getServer('HTTP_HOST'),
|
||||
'url' => 'http://'.$request->getServer('HTTP_HOST'),
|
||||
],
|
||||
],
|
||||
'legalName' => '',
|
||||
|
@ -1076,7 +1076,7 @@ foreach ($providers as $key => $provider) {
|
|||
$collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'label' => 'OAuth '.ucfirst($key).' ID',
|
||||
'key' => 'usersOauth'.ucfirst($key) . 'Appid',
|
||||
'key' => 'usersOauth'.ucfirst($key).'Appid',
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'required' => false,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'AF' => 'Afganistán',
|
||||
'AO' => 'Angola',
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
return [
|
||||
'AF' => 'Africa',
|
||||
'AN' => 'Antartide',
|
||||
'AS' => 'Asia',
|
||||
'EU' => 'Europa',
|
||||
'NA' => 'Nord America',
|
||||
'OC' => 'Oceania',
|
||||
'SA' => 'Sud America',
|
||||
];
|
||||
<?php
|
||||
|
||||
return [
|
||||
'AF' => 'Africa',
|
||||
'AN' => 'Antartide',
|
||||
'AS' => 'Asia',
|
||||
'EU' => 'Europa',
|
||||
'NA' => 'Nord America',
|
||||
'OC' => 'Oceania',
|
||||
'SA' => 'Sud America',
|
||||
];
|
||||
|
|
|
@ -1,198 +1,198 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'AF' => 'Afghanistan',
|
||||
'AO' => 'Angola',
|
||||
'AL' => 'Albania',
|
||||
'AD' => 'Andorra',
|
||||
'AE' => 'Emirati Arabi Uniti',
|
||||
'AR' => 'Argentina',
|
||||
'AM' => 'Armenia',
|
||||
'AG' => 'Antigua e Barbuda',
|
||||
'AU' => 'Australia',
|
||||
'AT' => 'Austria',
|
||||
'AZ' => 'Azerbaigian',
|
||||
'BI' => 'Burundi',
|
||||
'BE' => 'Belgio',
|
||||
'BJ' => 'Benin',
|
||||
'BF' => 'Burkina Faso',
|
||||
'BD' => 'Bangladesh',
|
||||
'BG' => 'Bulgaria',
|
||||
'BH' => 'Bahrein',
|
||||
'BS' => 'Bahamas',
|
||||
"BA" => "Bosnia ed Erzegovina",
|
||||
'BY' => 'Bielorussia',
|
||||
'BZ' => 'Belize',
|
||||
'BO' => 'Bolivia',
|
||||
'BR' => 'Brasile',
|
||||
'BB' => 'Barbados',
|
||||
'BN' => 'Brunei',
|
||||
'BT' => 'Bhutan',
|
||||
'BW' => 'Botswana',
|
||||
"CF" => "Repubblica centrafricana",
|
||||
'CA' => 'Canada',
|
||||
'CH' => 'Svizzera',
|
||||
'CL' => 'Cile',
|
||||
'CN' => 'Cina',
|
||||
'CI' => 'Costa d\'Avorio',
|
||||
'CM' => 'Camerun',
|
||||
'CD' => 'DR Congo',
|
||||
'CG' => 'Repubblica del Congo',
|
||||
'CO' => 'Colombia',
|
||||
'KM' => 'Comore',
|
||||
'CV' => 'Capo Verde',
|
||||
'CR' => 'Costa Rica',
|
||||
'CU' => 'Cuba',
|
||||
'CY' => 'Cipro',
|
||||
'CZ' => 'Czechia',
|
||||
'DE' => 'Germania',
|
||||
'DJ' => 'Gibuti',
|
||||
'DM' => 'Dominica',
|
||||
'DK' => 'Danimarca',
|
||||
'DO' => 'Repubblica Dominicana',
|
||||
'DZ' => 'Algeria',
|
||||
'EC' => 'Ecuador',
|
||||
'EG' => 'Egitto',
|
||||
'ER' => 'Eritrea',
|
||||
'ES' => 'Spagna',
|
||||
'EE' => 'Estonia',
|
||||
'ET' => 'Etiopia',
|
||||
'FI' => 'Finlandia',
|
||||
'FJ' => 'Figi',
|
||||
'FR' => 'France',
|
||||
'FM' => 'Micronesia',
|
||||
'GA' => 'Gabon',
|
||||
'GB' => 'Regno Unito',
|
||||
'GE' => 'Georgia',
|
||||
'GH' => 'Ghana',
|
||||
'GN' => 'Guinea',
|
||||
'GM' => 'Gambia',
|
||||
'GW' => 'Guinea-Bissau',
|
||||
'GQ' => 'Guinea equatoriale',
|
||||
'GR' => 'Grecia',
|
||||
'GD' => 'Grenada',
|
||||
'GT' => 'Guatemala',
|
||||
'GY' => 'Guyana',
|
||||
'HN' => 'Honduras',
|
||||
'HR' => 'Croazia',
|
||||
'HT' => 'Haiti',
|
||||
'HU' => 'Ungheria',
|
||||
'ID' => 'Indonesia',
|
||||
'IN' => 'India',
|
||||
'IE' => 'Irlanda',
|
||||
'IR' => 'Iran',
|
||||
'IQ' => 'Iraq',
|
||||
'IS' => 'Islanda',
|
||||
'IL' => 'Israele',
|
||||
'IT' => 'Italia',
|
||||
'JM' => 'Giamaica',
|
||||
'JO' => 'Jordan',
|
||||
'JP' => 'Giappone',
|
||||
'KZ' => 'Kazakistan',
|
||||
'KE' => 'Kenya',
|
||||
'KG' => 'Kirghizistan',
|
||||
'KH' => 'Cambogia',
|
||||
'KI' => 'Kiribati',
|
||||
'KN' => 'Saint Kitts e Nevis',
|
||||
"KR" => "Corea del Sud",
|
||||
'KW' => 'Kuwait',
|
||||
'LA' => 'Laos',
|
||||
'LB' => 'Libano',
|
||||
'LR' => 'Liberia',
|
||||
'LY' => 'Libia',
|
||||
'LC' => 'Santa Lucia',
|
||||
'LI' => 'Liechtenstein',
|
||||
'LK' => 'Sri Lanka',
|
||||
'LS' => 'Lesotho',
|
||||
'LT' => 'Lituania',
|
||||
'LU' => 'Lussemburgo',
|
||||
'LV' => 'Lettonia',
|
||||
'MA' => 'Marocco',
|
||||
'MC' => 'Monaco',
|
||||
'MD' => 'Moldavia',
|
||||
'MG' => 'Madagascar',
|
||||
'MV' => 'Maldive',
|
||||
'MX' => 'Messico',
|
||||
'MH' => 'Isole Marshall',
|
||||
'MK' => 'Macedonia',
|
||||
'ML' => 'Mali',
|
||||
'MT' => 'Malta',
|
||||
'MM' => 'Myanmar',
|
||||
'ME' => 'Montenegro',
|
||||
'MN' => 'Mongolia',
|
||||
'MZ' => 'Mozambico',
|
||||
'MR' => 'Mauritania',
|
||||
'MU' => 'Mauritius',
|
||||
'MW' => 'Malawi',
|
||||
'MY' => 'Malaysia',
|
||||
'NA' => 'Namibia',
|
||||
'NE' => 'Niger',
|
||||
'NG' => 'Nigeria',
|
||||
'NI' => 'Nicaragua',
|
||||
'NL' => 'Paesi Bassi',
|
||||
'NO' => 'Norvegia',
|
||||
'NP' => 'Nepal',
|
||||
'NR' => 'Nauru',
|
||||
'NZ' => 'Nuova Zelanda',
|
||||
'OM' => 'Oman',
|
||||
'PK' => 'Pakistan',
|
||||
'PA' => 'Panama',
|
||||
'PE' => 'Perù',
|
||||
'PH' => 'Filippine',
|
||||
'PW' => 'Palau',
|
||||
'PG' => 'Papua New Guinea',
|
||||
'PL' => 'Polonia',
|
||||
'KP' => 'Corea del Nord',
|
||||
'PT' => 'Portogallo',
|
||||
'PY' => 'Paraguay',
|
||||
'QA' => 'Qatar',
|
||||
'RO' => 'Romania',
|
||||
'RU' => 'Russia',
|
||||
'RW' => 'Ruanda',
|
||||
'SA' => 'Arabia Saudita',
|
||||
'SD' => 'Sudan',
|
||||
'SN' => 'Senegal',
|
||||
'SG' => 'Singapore',
|
||||
'SB' => 'Isole Salomone',
|
||||
'SL' => 'Sierra Leone',
|
||||
'SV' => 'El Salvador',
|
||||
'SM' => 'San Marino',
|
||||
'SO' => 'Somalia',
|
||||
'RS' => 'Serbia',
|
||||
'SS' => 'Sudan del Sud',
|
||||
'ST' => 'São Tomé and Príncipe',
|
||||
'SR' => 'Suriname',
|
||||
'SK' => 'Slovacchia',
|
||||
'SI' => 'Slovenia',
|
||||
'SE' => 'Svezia',
|
||||
'SZ' => 'Swaziland',
|
||||
'SC' => 'Seychelles',
|
||||
'SY' => 'Siria',
|
||||
'TD' => 'Chad',
|
||||
'TG' => 'Togo',
|
||||
'TH' => 'Thailand',
|
||||
'TJ' => 'Tagikistan',
|
||||
'TM' => 'Turkmenistan',
|
||||
'TL' => 'Timor Est',
|
||||
'TO' => 'Tonga',
|
||||
'TT' => 'Trinidad e Tobago',
|
||||
'TN' => 'Tunisia',
|
||||
'TR' => 'Turchia',
|
||||
'TV' => 'Tuvalu',
|
||||
'TZ' => 'Tanzania',
|
||||
'UG' => 'Uganda',
|
||||
'UA' => 'Ucraina',
|
||||
'UY' => 'Uruguay',
|
||||
'US' => 'Stati Uniti',
|
||||
'UZ' => 'Uzbekistan',
|
||||
'VA' => 'Città del Vaticano',
|
||||
'VC' => 'Saint Vincent e Grenadine',
|
||||
'VE' => 'Venezuela',
|
||||
'VN' => 'Vietnam',
|
||||
'VU' => 'Vanuatu',
|
||||
'WS' => 'Samoa',
|
||||
'YE' => 'Yemen',
|
||||
'ZA' => 'Sudafrica',
|
||||
'ZM' => 'Zambia',
|
||||
'ZW' => 'Zimbabwe',
|
||||
];
|
||||
<?php
|
||||
|
||||
return [
|
||||
'AF' => 'Afghanistan',
|
||||
'AO' => 'Angola',
|
||||
'AL' => 'Albania',
|
||||
'AD' => 'Andorra',
|
||||
'AE' => 'Emirati Arabi Uniti',
|
||||
'AR' => 'Argentina',
|
||||
'AM' => 'Armenia',
|
||||
'AG' => 'Antigua e Barbuda',
|
||||
'AU' => 'Australia',
|
||||
'AT' => 'Austria',
|
||||
'AZ' => 'Azerbaigian',
|
||||
'BI' => 'Burundi',
|
||||
'BE' => 'Belgio',
|
||||
'BJ' => 'Benin',
|
||||
'BF' => 'Burkina Faso',
|
||||
'BD' => 'Bangladesh',
|
||||
'BG' => 'Bulgaria',
|
||||
'BH' => 'Bahrein',
|
||||
'BS' => 'Bahamas',
|
||||
'BA' => 'Bosnia ed Erzegovina',
|
||||
'BY' => 'Bielorussia',
|
||||
'BZ' => 'Belize',
|
||||
'BO' => 'Bolivia',
|
||||
'BR' => 'Brasile',
|
||||
'BB' => 'Barbados',
|
||||
'BN' => 'Brunei',
|
||||
'BT' => 'Bhutan',
|
||||
'BW' => 'Botswana',
|
||||
'CF' => 'Repubblica centrafricana',
|
||||
'CA' => 'Canada',
|
||||
'CH' => 'Svizzera',
|
||||
'CL' => 'Cile',
|
||||
'CN' => 'Cina',
|
||||
'CI' => 'Costa d\'Avorio',
|
||||
'CM' => 'Camerun',
|
||||
'CD' => 'DR Congo',
|
||||
'CG' => 'Repubblica del Congo',
|
||||
'CO' => 'Colombia',
|
||||
'KM' => 'Comore',
|
||||
'CV' => 'Capo Verde',
|
||||
'CR' => 'Costa Rica',
|
||||
'CU' => 'Cuba',
|
||||
'CY' => 'Cipro',
|
||||
'CZ' => 'Czechia',
|
||||
'DE' => 'Germania',
|
||||
'DJ' => 'Gibuti',
|
||||
'DM' => 'Dominica',
|
||||
'DK' => 'Danimarca',
|
||||
'DO' => 'Repubblica Dominicana',
|
||||
'DZ' => 'Algeria',
|
||||
'EC' => 'Ecuador',
|
||||
'EG' => 'Egitto',
|
||||
'ER' => 'Eritrea',
|
||||
'ES' => 'Spagna',
|
||||
'EE' => 'Estonia',
|
||||
'ET' => 'Etiopia',
|
||||
'FI' => 'Finlandia',
|
||||
'FJ' => 'Figi',
|
||||
'FR' => 'France',
|
||||
'FM' => 'Micronesia',
|
||||
'GA' => 'Gabon',
|
||||
'GB' => 'Regno Unito',
|
||||
'GE' => 'Georgia',
|
||||
'GH' => 'Ghana',
|
||||
'GN' => 'Guinea',
|
||||
'GM' => 'Gambia',
|
||||
'GW' => 'Guinea-Bissau',
|
||||
'GQ' => 'Guinea equatoriale',
|
||||
'GR' => 'Grecia',
|
||||
'GD' => 'Grenada',
|
||||
'GT' => 'Guatemala',
|
||||
'GY' => 'Guyana',
|
||||
'HN' => 'Honduras',
|
||||
'HR' => 'Croazia',
|
||||
'HT' => 'Haiti',
|
||||
'HU' => 'Ungheria',
|
||||
'ID' => 'Indonesia',
|
||||
'IN' => 'India',
|
||||
'IE' => 'Irlanda',
|
||||
'IR' => 'Iran',
|
||||
'IQ' => 'Iraq',
|
||||
'IS' => 'Islanda',
|
||||
'IL' => 'Israele',
|
||||
'IT' => 'Italia',
|
||||
'JM' => 'Giamaica',
|
||||
'JO' => 'Jordan',
|
||||
'JP' => 'Giappone',
|
||||
'KZ' => 'Kazakistan',
|
||||
'KE' => 'Kenya',
|
||||
'KG' => 'Kirghizistan',
|
||||
'KH' => 'Cambogia',
|
||||
'KI' => 'Kiribati',
|
||||
'KN' => 'Saint Kitts e Nevis',
|
||||
'KR' => 'Corea del Sud',
|
||||
'KW' => 'Kuwait',
|
||||
'LA' => 'Laos',
|
||||
'LB' => 'Libano',
|
||||
'LR' => 'Liberia',
|
||||
'LY' => 'Libia',
|
||||
'LC' => 'Santa Lucia',
|
||||
'LI' => 'Liechtenstein',
|
||||
'LK' => 'Sri Lanka',
|
||||
'LS' => 'Lesotho',
|
||||
'LT' => 'Lituania',
|
||||
'LU' => 'Lussemburgo',
|
||||
'LV' => 'Lettonia',
|
||||
'MA' => 'Marocco',
|
||||
'MC' => 'Monaco',
|
||||
'MD' => 'Moldavia',
|
||||
'MG' => 'Madagascar',
|
||||
'MV' => 'Maldive',
|
||||
'MX' => 'Messico',
|
||||
'MH' => 'Isole Marshall',
|
||||
'MK' => 'Macedonia',
|
||||
'ML' => 'Mali',
|
||||
'MT' => 'Malta',
|
||||
'MM' => 'Myanmar',
|
||||
'ME' => 'Montenegro',
|
||||
'MN' => 'Mongolia',
|
||||
'MZ' => 'Mozambico',
|
||||
'MR' => 'Mauritania',
|
||||
'MU' => 'Mauritius',
|
||||
'MW' => 'Malawi',
|
||||
'MY' => 'Malaysia',
|
||||
'NA' => 'Namibia',
|
||||
'NE' => 'Niger',
|
||||
'NG' => 'Nigeria',
|
||||
'NI' => 'Nicaragua',
|
||||
'NL' => 'Paesi Bassi',
|
||||
'NO' => 'Norvegia',
|
||||
'NP' => 'Nepal',
|
||||
'NR' => 'Nauru',
|
||||
'NZ' => 'Nuova Zelanda',
|
||||
'OM' => 'Oman',
|
||||
'PK' => 'Pakistan',
|
||||
'PA' => 'Panama',
|
||||
'PE' => 'Perù',
|
||||
'PH' => 'Filippine',
|
||||
'PW' => 'Palau',
|
||||
'PG' => 'Papua New Guinea',
|
||||
'PL' => 'Polonia',
|
||||
'KP' => 'Corea del Nord',
|
||||
'PT' => 'Portogallo',
|
||||
'PY' => 'Paraguay',
|
||||
'QA' => 'Qatar',
|
||||
'RO' => 'Romania',
|
||||
'RU' => 'Russia',
|
||||
'RW' => 'Ruanda',
|
||||
'SA' => 'Arabia Saudita',
|
||||
'SD' => 'Sudan',
|
||||
'SN' => 'Senegal',
|
||||
'SG' => 'Singapore',
|
||||
'SB' => 'Isole Salomone',
|
||||
'SL' => 'Sierra Leone',
|
||||
'SV' => 'El Salvador',
|
||||
'SM' => 'San Marino',
|
||||
'SO' => 'Somalia',
|
||||
'RS' => 'Serbia',
|
||||
'SS' => 'Sudan del Sud',
|
||||
'ST' => 'São Tomé and Príncipe',
|
||||
'SR' => 'Suriname',
|
||||
'SK' => 'Slovacchia',
|
||||
'SI' => 'Slovenia',
|
||||
'SE' => 'Svezia',
|
||||
'SZ' => 'Swaziland',
|
||||
'SC' => 'Seychelles',
|
||||
'SY' => 'Siria',
|
||||
'TD' => 'Chad',
|
||||
'TG' => 'Togo',
|
||||
'TH' => 'Thailand',
|
||||
'TJ' => 'Tagikistan',
|
||||
'TM' => 'Turkmenistan',
|
||||
'TL' => 'Timor Est',
|
||||
'TO' => 'Tonga',
|
||||
'TT' => 'Trinidad e Tobago',
|
||||
'TN' => 'Tunisia',
|
||||
'TR' => 'Turchia',
|
||||
'TV' => 'Tuvalu',
|
||||
'TZ' => 'Tanzania',
|
||||
'UG' => 'Uganda',
|
||||
'UA' => 'Ucraina',
|
||||
'UY' => 'Uruguay',
|
||||
'US' => 'Stati Uniti',
|
||||
'UZ' => 'Uzbekistan',
|
||||
'VA' => 'Città del Vaticano',
|
||||
'VC' => 'Saint Vincent e Grenadine',
|
||||
'VE' => 'Venezuela',
|
||||
'VN' => 'Vietnam',
|
||||
'VU' => 'Vanuatu',
|
||||
'WS' => 'Samoa',
|
||||
'YE' => 'Yemen',
|
||||
'ZA' => 'Sudafrica',
|
||||
'ZM' => 'Zambia',
|
||||
'ZW' => 'Zimbabwe',
|
||||
];
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'settings.inspire' => '"L\'arte di essere saggi è l\'arte di sapere cosa trascurare."', // Questa è la riga stampata nella homepage e nella console 'view-source'
|
||||
'settings.locale' => 'it',
|
||||
'settings.direction' => 'ltr',
|
||||
// Servizio - Utenti
|
||||
'auth.emails.team' => '%s Squadra',
|
||||
'auth.emails.confirm.title' => 'Conferma dell\'account',
|
||||
'auth.emails.confirm.body' => 'en.email.auth.confirm.tpl',
|
||||
'auth.emails.recovery.title' => 'Reimpostazione della password',
|
||||
'auth.emails.recovery.body' => 'en.email.auth.recovery.tpl',
|
||||
'auth.emails.invitation.title' => 'Invito a %s squadra %s',
|
||||
'auth.emails.invitation.body' => 'en.email.auth.invitation.tpl',
|
||||
'locale.country.unknown' => 'Sconosciuto',
|
||||
'countries' => include 'it.countries.php',
|
||||
'continents' => include 'it.continents.php',
|
||||
];
|
||||
<?php
|
||||
|
||||
return [
|
||||
'settings.inspire' => '"L\'arte di essere saggi è l\'arte di sapere cosa trascurare."', // Questa è la riga stampata nella homepage e nella console 'view-source'
|
||||
'settings.locale' => 'it',
|
||||
'settings.direction' => 'ltr',
|
||||
// Servizio - Utenti
|
||||
'auth.emails.team' => '%s Squadra',
|
||||
'auth.emails.confirm.title' => 'Conferma dell\'account',
|
||||
'auth.emails.confirm.body' => 'en.email.auth.confirm.tpl',
|
||||
'auth.emails.recovery.title' => 'Reimpostazione della password',
|
||||
'auth.emails.recovery.body' => 'en.email.auth.recovery.tpl',
|
||||
'auth.emails.invitation.title' => 'Invito a %s squadra %s',
|
||||
'auth.emails.invitation.body' => 'en.email.auth.invitation.tpl',
|
||||
'locale.country.unknown' => 'Sconosciuto',
|
||||
'countries' => include 'it.countries.php',
|
||||
'continents' => include 'it.continents.php',
|
||||
];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
const VERSION = '0.1.15';
|
||||
|
||||
return VERSION;
|
||||
|
|
|
@ -49,9 +49,9 @@ $utopia->post('/v1/auth/register')
|
|||
->action(
|
||||
function ($email, $password, $confirm, $success, $failure, $name) use ($request, $response, $register, $audit, $projectDB, $project, $webhook) {
|
||||
if ('console' === $project->getUid()) {
|
||||
$whitlistEmails = $project->getAttribute('authWhitelistEmails');
|
||||
$whitlistIPs = $project->getAttribute('authWhitelistIPs');
|
||||
$whitlistDomains = $project->getAttribute('authWhitelistDomains');
|
||||
$whitlistEmails = $project->getAttribute('authWhitelistEmails');
|
||||
$whitlistIPs = $project->getAttribute('authWhitelistIPs');
|
||||
$whitlistDomains = $project->getAttribute('authWhitelistDomains');
|
||||
|
||||
if (!empty($whitlistEmails) && !in_array($email, $whitlistEmails)) {
|
||||
throw new Exception('Console registration is restricted to specific emails. Contact your administrator for more information.', 401);
|
||||
|
@ -61,11 +61,11 @@ $utopia->post('/v1/auth/register')
|
|||
throw new Exception('Console registration is restricted to specific IPs. Contact your administrator for more information.', 401);
|
||||
}
|
||||
|
||||
if (!empty($whitlistDomains) && !in_array(substr(strrchr($email, "@"), 1), $whitlistDomains)) {
|
||||
if (!empty($whitlistDomains) && !in_array(substr(strrchr($email, '@'), 1), $whitlistDomains)) {
|
||||
throw new Exception('Console registration is restricted to specific domains. Contact your administrator for more information.', 401);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$profile = $projectDB->getCollection([ // Get user by email address
|
||||
'limit' => 1,
|
||||
'first' => true,
|
||||
|
@ -77,7 +77,7 @@ $utopia->post('/v1/auth/register')
|
|||
|
||||
if (!empty($profile)) {
|
||||
if ($failure) {
|
||||
$response->redirect($failure . '?message=User already registered');
|
||||
$response->redirect($failure.'?message=User already registered');
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -778,7 +778,7 @@ $utopia->get('/v1/auth/oauth/:provider/redirect')
|
|||
}
|
||||
|
||||
$oauthID = $oauth->getUserID($accessToken);
|
||||
|
||||
|
||||
if (empty($oauthID)) {
|
||||
if (!empty($state['failure'])) {
|
||||
$response->redirect($state['failure'], 301, 0);
|
||||
|
@ -788,7 +788,7 @@ $utopia->get('/v1/auth/oauth/:provider/redirect')
|
|||
}
|
||||
|
||||
$current = Auth::tokenVerify($user->getAttribute('tokens', []), Auth::TOKEN_TYPE_LOGIN, Auth::$secret);
|
||||
|
||||
|
||||
if ($current) {
|
||||
$projectDB->deleteDocument($current); //throw new Exception('User already logged in', 401);
|
||||
}
|
||||
|
@ -802,7 +802,6 @@ $utopia->get('/v1/auth/oauth/:provider/redirect')
|
|||
],
|
||||
]) : $user;
|
||||
|
||||
|
||||
if (empty($user)) { // No user logged in or with oauth provider ID, create new one or connect with account with same email
|
||||
$name = $oauth->getUserName($accessToken);
|
||||
$email = $oauth->getUserEmail($accessToken);
|
||||
|
|
|
@ -5,7 +5,6 @@ include_once 'shared/web.php';
|
|||
global $utopia, $response, $request, $layout, $version, $providers;
|
||||
|
||||
use Utopia\View;
|
||||
use Utopia\Locale\Locale;
|
||||
use Database\Database;
|
||||
use Database\Validator\UID;
|
||||
|
||||
|
@ -83,7 +82,7 @@ $utopia->get('/console/account')
|
|||
;
|
||||
|
||||
$layout
|
||||
->setParam('title', 'Account - ' . APP_NAME)
|
||||
->setParam('title', 'Account - '.APP_NAME)
|
||||
->setParam('body', $page);
|
||||
});
|
||||
|
||||
|
|
|
@ -119,17 +119,17 @@ $utopia->post('/v1/database')
|
|||
->action(
|
||||
function ($name, $read, $write, $rules) use ($response, $projectDB, $webhook, $audit) {
|
||||
$parsedRules = [];
|
||||
|
||||
|
||||
foreach ($rules as &$rule) {
|
||||
$parsedRules[] = array_merge([
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'$permissions' => [
|
||||
'read' => $read,
|
||||
'write' => $write,
|
||||
]
|
||||
],
|
||||
], $rule);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$data = $projectDB->createDocument([
|
||||
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
|
||||
|
@ -201,16 +201,16 @@ $utopia->put('/v1/database/:collectionId')
|
|||
if (empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
|
||||
throw new Exception('Collection not found', 404);
|
||||
}
|
||||
|
||||
|
||||
$parsedRules = [];
|
||||
|
||||
|
||||
foreach ($rules as &$rule) {
|
||||
$parsedRules[] = array_merge([
|
||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||
'$permissions' => [
|
||||
'read' => $read,
|
||||
'write' => $write,
|
||||
]
|
||||
],
|
||||
], $rule);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,11 +115,11 @@ $utopia->get('/v1/health/storage/local')
|
|||
function () use ($response) {
|
||||
$device = new Local();
|
||||
|
||||
if (!is_readable($device->getRoot(). '/..')) {
|
||||
if (!is_readable($device->getRoot().'/..')) {
|
||||
throw new Exception('Device is not readable');
|
||||
}
|
||||
|
||||
if (!is_writable($device->getRoot(). '/..')) {
|
||||
if (!is_writable($device->getRoot().'/..')) {
|
||||
throw new Exception('Device is not writable');
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ include_once 'shared/web.php';
|
|||
global $utopia, $response, $request, $layout, $version, $providers, $sdks;
|
||||
|
||||
use Utopia\View;
|
||||
use Utopia\Locale\Locale;
|
||||
|
||||
$layout
|
||||
->setParam('title', APP_NAME)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Created by PhpStorm.
|
||||
* User: eldadfux
|
||||
|
|
113
app/init.php
113
app/init.php
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
// Init
|
||||
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
if (file_exists(__DIR__.'/../vendor/autoload.php')) {
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
}
|
||||
|
||||
use Utopia\App;
|
||||
|
@ -18,48 +18,48 @@ use Utopia\Locale\Locale;
|
|||
use Utopia\Registry\Registry;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
const APP_NAME = 'Appwrite';
|
||||
const APP_DOMAIN = 'appwrite.io';
|
||||
const APP_EMAIL_TEAM = 'team@' . APP_DOMAIN;
|
||||
const APP_EMAIL_SECURITY = 'security@' . APP_DOMAIN;
|
||||
const APP_USERAGENT = APP_NAME . '-Server/%s Please report abuse at ' . APP_EMAIL_SECURITY;
|
||||
const APP_MODE_ADMIN = 'admin';
|
||||
const APP_LOCALES = ['en', 'he', 'pt-br', 'es'];
|
||||
const APP_PAGING_LIMIT = 15;
|
||||
const APP_NAME = 'Appwrite';
|
||||
const APP_DOMAIN = 'appwrite.io';
|
||||
const APP_EMAIL_TEAM = 'team@'.APP_DOMAIN;
|
||||
const APP_EMAIL_SECURITY = 'security@'.APP_DOMAIN;
|
||||
const APP_USERAGENT = APP_NAME.'-Server/%s Please report abuse at '.APP_EMAIL_SECURITY;
|
||||
const APP_MODE_ADMIN = 'admin';
|
||||
const APP_LOCALES = ['en', 'he', 'pt-br', 'es'];
|
||||
const APP_PAGING_LIMIT = 15;
|
||||
|
||||
$register = new Registry();
|
||||
$request = new Request();
|
||||
$response = new Response();
|
||||
$register = new Registry();
|
||||
$request = new Request();
|
||||
$response = new Response();
|
||||
|
||||
/**
|
||||
/*
|
||||
* ENV vars
|
||||
*/
|
||||
$env = $request->getServer('_APP_ENV', App::ENV_TYPE_PRODUCTION);
|
||||
$domain = $request->getServer('HTTP_HOST', '');
|
||||
$version = include __DIR__ . '/../app/config/version.php';
|
||||
$providers = include __DIR__ . '/../app/config/providers.php'; // OAuth providers list
|
||||
$collections = include __DIR__ . '/../app/config/collections.php'; // OAuth providers list
|
||||
$redisHost = $request->getServer('_APP_REDIS_HOST', '');
|
||||
$redisPort = $request->getServer('_APP_REDIS_PORT', '');
|
||||
$utopia = new App('Asia/Tel_Aviv', $env);
|
||||
$port = (string)(isset($_SERVER['HTTP_HOST'])) ? parse_url($_SERVER['HTTP_HOST'], PHP_URL_PORT) : '';
|
||||
$env = $request->getServer('_APP_ENV', App::ENV_TYPE_PRODUCTION);
|
||||
$domain = $request->getServer('HTTP_HOST', '');
|
||||
$version = include __DIR__.'/../app/config/version.php';
|
||||
$providers = include __DIR__.'/../app/config/providers.php'; // OAuth providers list
|
||||
$collections = include __DIR__.'/../app/config/collections.php'; // OAuth providers list
|
||||
$redisHost = $request->getServer('_APP_REDIS_HOST', '');
|
||||
$redisPort = $request->getServer('_APP_REDIS_PORT', '');
|
||||
$utopia = new App('Asia/Tel_Aviv', $env);
|
||||
$port = (string) (isset($_SERVER['HTTP_HOST'])) ? parse_url($_SERVER['HTTP_HOST'], PHP_URL_PORT) : '';
|
||||
|
||||
Resque::setBackend($redisHost . ':' . $redisPort);
|
||||
Resque::setBackend($redisHost.':'.$redisPort);
|
||||
|
||||
define('COOKIE_DOMAIN', ($request->getServer('HTTP_HOST', null) === 'localhost' || $request->getServer('HTTP_HOST', null) === 'localhost:' . $port) ? false : '.' . $request->getServer('HTTP_HOST', false));
|
||||
define('COOKIE_DOMAIN', ($request->getServer('HTTP_HOST', null) === 'localhost' || $request->getServer('HTTP_HOST', null) === 'localhost:'.$port) ? false : '.'.$request->getServer('HTTP_HOST', false));
|
||||
|
||||
/**
|
||||
/*
|
||||
* Registry
|
||||
*/
|
||||
$register->set('db', function () use ($request) { // Register DB connection
|
||||
$dbHost = $request->getServer('_APP_DB_HOST', '');
|
||||
$dbUser = $request->getServer('_APP_DB_USER', '');
|
||||
$dbPass = $request->getServer('_APP_DB_PASS', '');
|
||||
$dbScheme = $request->getServer('_APP_DB_SCHEMA', '');
|
||||
$dbHost = $request->getServer('_APP_DB_HOST', '');
|
||||
$dbUser = $request->getServer('_APP_DB_USER', '');
|
||||
$dbPass = $request->getServer('_APP_DB_PASS', '');
|
||||
$dbScheme = $request->getServer('_APP_DB_SCHEMA', '');
|
||||
|
||||
$pdo = new PDO("mysql:host={$dbHost};dbname={$dbScheme};charset=utf8mb4", $dbUser, $dbPass, array(
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
|
||||
PDO::ATTR_TIMEOUT => 5 // Seconds
|
||||
PDO::ATTR_TIMEOUT => 5, // Seconds
|
||||
));
|
||||
|
||||
// Connection settings
|
||||
|
@ -73,7 +73,7 @@ $register->set('influxdb', function () use ($request) { // Register DB connectio
|
|||
$port = $request->getServer('_APP_INFLUXDB_PORT', '');
|
||||
|
||||
if (empty($host) || empty($port)) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
$client = new InfluxDB\Client($host, $port, '', '', false, false, 5);
|
||||
|
@ -93,6 +93,7 @@ $register->set('cache', function () use ($redisHost, $redisPort) { // Register c
|
|||
$redis = new Redis();
|
||||
|
||||
$redis->connect($redisHost, $redisPort);
|
||||
|
||||
return $redis;
|
||||
});
|
||||
$register->set('smtp', function () use ($request) {
|
||||
|
@ -103,33 +104,33 @@ $register->set('smtp', function () use ($request) {
|
|||
$username = $request->getServer('_APP_SMTP_USERNAME', '');
|
||||
$password = $request->getServer('_APP_SMTP_PASSWORD', '');
|
||||
|
||||
$mail->XMailer = 'Appwrite Mailer';
|
||||
$mail->Host = $request->getServer('_APP_SMTP_HOST', 'smtp');
|
||||
$mail->Port = $request->getServer('_APP_SMTP_PORT', 25);
|
||||
$mail->SMTPAuth = (!empty($username) && !empty($password));
|
||||
$mail->Username = $username;
|
||||
$mail->Password = $password;
|
||||
$mail->XMailer = 'Appwrite Mailer';
|
||||
$mail->Host = $request->getServer('_APP_SMTP_HOST', 'smtp');
|
||||
$mail->Port = $request->getServer('_APP_SMTP_PORT', 25);
|
||||
$mail->SMTPAuth = (!empty($username) && !empty($password));
|
||||
$mail->Username = $username;
|
||||
$mail->Password = $password;
|
||||
$mail->SMTPSecure = $request->getServer('_APP_SMTP_SECURE', '');
|
||||
|
||||
$mail->setFrom('team@appwrite.io', APP_NAME . ' Team');
|
||||
$mail->addReplyTo('team@appwrite.io', APP_NAME . ' Team');
|
||||
$mail->setFrom('team@appwrite.io', APP_NAME.' Team');
|
||||
$mail->addReplyTo('team@appwrite.io', APP_NAME.' Team');
|
||||
|
||||
$mail->isHTML(true);
|
||||
|
||||
|
||||
return $mail;
|
||||
});
|
||||
|
||||
/**
|
||||
/*
|
||||
* Localization
|
||||
*/
|
||||
$locale = $request->getParam('locale', $request->getHeader('X-Appwrite-Locale', null));
|
||||
|
||||
Locale::$exceptions = false;
|
||||
|
||||
Locale::setLanguage('en', include __DIR__ . '/config/locale/en.php');
|
||||
Locale::setLanguage('he', include __DIR__ . '/config/locale/he.php');
|
||||
Locale::setLanguage('pt-br', include __DIR__ . '/config/locale/pt-br.php');
|
||||
Locale::setLanguage('es', include __DIR__ . '/config/locale/es.php');
|
||||
Locale::setLanguage('en', include __DIR__.'/config/locale/en.php');
|
||||
Locale::setLanguage('he', include __DIR__.'/config/locale/he.php');
|
||||
Locale::setLanguage('pt-br', include __DIR__.'/config/locale/pt-br.php');
|
||||
Locale::setLanguage('es', include __DIR__.'/config/locale/es.php');
|
||||
|
||||
if (in_array($locale, APP_LOCALES)) {
|
||||
Locale::setDefault($locale);
|
||||
|
@ -139,11 +140,11 @@ stream_context_set_default([ // Set global user agent and http settings
|
|||
'http' => [
|
||||
'method' => 'GET',
|
||||
'user_agent' => sprintf(APP_USERAGENT, $version),
|
||||
'timeout' => 2
|
||||
]
|
||||
'timeout' => 2,
|
||||
],
|
||||
]);
|
||||
|
||||
/**
|
||||
/*
|
||||
* Auth & Project Scope
|
||||
*/
|
||||
$consoleDB = new Database();
|
||||
|
@ -165,19 +166,19 @@ if (is_null($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS !== $pro
|
|||
|
||||
$mode = $request->getParam('mode', $request->getHeader('X-Appwrite-Mode', 'default'));
|
||||
|
||||
Auth::setCookieName('a-session-' . $project->getUid());
|
||||
Auth::setCookieName('a-session-'.$project->getUid());
|
||||
|
||||
if (APP_MODE_ADMIN === $mode) {
|
||||
Auth::setCookieName('a-session-' . $console->getUid());
|
||||
Auth::setCookieName('a-session-'.$console->getUid());
|
||||
}
|
||||
|
||||
$session = Auth::decodeSession($request->getCookie(Auth::$cookieName, $request->getHeader('X-Appwrite-Key', '')));
|
||||
Auth::$unique = $session['id'];
|
||||
Auth::$secret = $session['secret'];
|
||||
$session = Auth::decodeSession($request->getCookie(Auth::$cookieName, $request->getHeader('X-Appwrite-Key', '')));
|
||||
Auth::$unique = $session['id'];
|
||||
Auth::$secret = $session['secret'];
|
||||
|
||||
$projectDB = new Database();
|
||||
$projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
|
||||
$projectDB->setNamespace('app_' . $project->getUid());
|
||||
$projectDB->setNamespace('app_'.$project->getUid());
|
||||
$projectDB->setMocks($collections);
|
||||
|
||||
$user = $projectDB->getDocument(Auth::$unique);
|
||||
|
@ -186,7 +187,7 @@ if (APP_MODE_ADMIN === $mode) {
|
|||
$user = $consoleDB->getDocument(Auth::$unique);
|
||||
|
||||
$user
|
||||
->setAttribute('$uid', 'admin-' . $user->getAttribute('$uid'))
|
||||
->setAttribute('$uid', 'admin-'.$user->getAttribute('$uid'))
|
||||
;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue