commit
41aeba0d11
8 changed files with 32 additions and 31 deletions
|
@ -83,7 +83,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
|
|||
* As recommended at:
|
||||
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
|
||||
*/
|
||||
if ($request->getServer('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
|
||||
if ($utopia->getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
|
||||
if(Config::getParam('protocol') !== 'https') {
|
||||
return $response->redirect('https://' . Config::getParam('domain').$request->getServer('REQUEST_URI'));
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ $utopia->error(function ($error /* @var $error Exception */) use ($request, $res
|
|||
|
||||
$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised
|
||||
|
||||
$output = ((App::ENV_TYPE_DEVELOPMENT == $env)) ? [
|
||||
$output = ((App::MODE_TYPE_DEVELOPMENT == $env)) ? [
|
||||
'message' => $error->getMessage(),
|
||||
'code' => $error->getCode(),
|
||||
'file' => $error->getFile(),
|
||||
|
|
|
@ -27,7 +27,7 @@ use GeoIp2\Database\Reader;
|
|||
|
||||
include_once __DIR__ . '/../shared/api.php';
|
||||
|
||||
$isDev = (App::ENV_TYPE_PRODUCTION !== $utopia->getEnv());
|
||||
$isDev = (App::MODE_TYPE_PRODUCTION !== $utopia->getMode());
|
||||
|
||||
$utopia->post('/v1/database/collections')
|
||||
->desc('Create Collection')
|
||||
|
|
|
@ -26,7 +26,7 @@ $utopia->get('/v1/locale')
|
|||
$countries = Locale::getText('countries');
|
||||
$continents = Locale::getText('continents');
|
||||
|
||||
if (App::ENV_TYPE_PRODUCTION !== $utopia->getEnv()) {
|
||||
if (App::MODE_TYPE_PRODUCTION !== $utopia->getMode()) {
|
||||
$ip = '79.177.241.94';
|
||||
}
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ $layout
|
|||
->setParam('class', 'unknown')
|
||||
->setParam('icon', '/images/favicon.png')
|
||||
->setParam('roles', $roles)
|
||||
->setParam('env', $utopia->getEnv())
|
||||
->setParam('env', $utopia->getMode())
|
||||
;
|
||||
|
||||
$utopia->init(function () use ($utopia, $response, $request, $layout) {
|
||||
$time = (60 * 60 * 24 * 45); // 45 days cache
|
||||
$isDev = (\Utopia\App::ENV_TYPE_DEVELOPMENT == Config::getParam('env'));
|
||||
$isDev = (\Utopia\App::MODE_TYPE_DEVELOPMENT == Config::getParam('env'));
|
||||
|
||||
$response
|
||||
->addHeader('Cache-Control', 'public, max-age='.$time)
|
||||
|
|
13
app/init.php
13
app/init.php
|
@ -50,6 +50,9 @@ const APP_SOCIAL_DEV = 'https://dev.to/appwrite';
|
|||
$register = new Registry();
|
||||
$request = new Request();
|
||||
$response = new Response();
|
||||
$utopia = new App('Asia/Tel_Aviv');
|
||||
|
||||
$utopia->setMode($utopia->getEnv('_APP_ENV', App::MODE_TYPE_PRODUCTION));
|
||||
|
||||
/*
|
||||
* ENV vars
|
||||
|
@ -60,7 +63,7 @@ Config::load('platforms', __DIR__.'/../app/config/platforms.php');
|
|||
Config::load('locales', __DIR__.'/../app/config/locales.php');
|
||||
Config::load('collections', __DIR__.'/../app/config/collections.php');
|
||||
|
||||
Config::setParam('env', $request->getServer('_APP_ENV', App::ENV_TYPE_PRODUCTION));
|
||||
Config::setParam('env', $utopia->getMode());
|
||||
Config::setParam('domain', $request->getServer('HTTP_HOST', ''));
|
||||
Config::setParam('domainVerification', false);
|
||||
Config::setParam('version', $request->getServer('_APP_VERSION', 'UNKNOWN'));
|
||||
|
@ -68,8 +71,6 @@ Config::setParam('protocol', $request->getServer('HTTP_X_FORWARDED_PROTO', $requ
|
|||
Config::setParam('port', (string) parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_PORT));
|
||||
Config::setParam('hostname', parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', null), PHP_URL_HOST));
|
||||
|
||||
$utopia = new App('Asia/Tel_Aviv', Config::getParam('env'));
|
||||
|
||||
Resque::setBackend($request->getServer('_APP_REDIS_HOST', '')
|
||||
.':'.$request->getServer('_APP_REDIS_PORT', ''));
|
||||
|
||||
|
@ -165,7 +166,7 @@ $register->set('smtp', function () use ($request) {
|
|||
/*
|
||||
* Localization
|
||||
*/
|
||||
$locale = $request->getParam('locale', $request->getHeader('X-Appwrite-Locale', null));
|
||||
$locale = $request->getParam('locale', $request->getHeader('X-Appwrite-Locale', ''));
|
||||
|
||||
Locale::$exceptions = false;
|
||||
|
||||
|
@ -242,7 +243,7 @@ $consoleDB->setNamespace('app_console'); // Should be replaced with param if we
|
|||
$consoleDB->setMocks(Config::getParam('collections', []));
|
||||
Authorization::disable();
|
||||
|
||||
$project = $consoleDB->getDocument($request->getParam('project', $request->getHeader('X-Appwrite-Project', null)));
|
||||
$project = $consoleDB->getDocument($request->getParam('project', $request->getHeader('X-Appwrite-Project', '')));
|
||||
|
||||
Authorization::enable();
|
||||
|
||||
|
@ -266,7 +267,7 @@ $response->addHeader('X-Debug-Fallback', 'false');
|
|||
|
||||
if(empty($session['id']) && empty($session['secret'])) {
|
||||
$response->addHeader('X-Debug-Fallback', 'true');
|
||||
$fallback = $request->getHeader('X-Fallback-Cookies', null);
|
||||
$fallback = $request->getHeader('X-Fallback-Cookies', '');
|
||||
$fallback = json_decode($fallback, true);
|
||||
$session = Auth::decodeSession(((isset($fallback[Auth::$cookieName])) ? $fallback[Auth::$cookieName] : ''));
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ class CertificatesV1
|
|||
throw new Exception('Renew isn\'t required');
|
||||
}
|
||||
|
||||
$staging = (Config::getParam('env') === App::ENV_TYPE_PRODUCTION) ? '' : ' --dry-run';
|
||||
$staging = (Config::getParam('env') === App::MODE_TYPE_PRODUCTION) ? '' : ' --dry-run';
|
||||
|
||||
$response = shell_exec("certbot certonly --webroot --noninteractive --agree-tos{$staging} --email security@appwrite.io \
|
||||
-w ".APP_STORAGE_CERTIFICATES." \
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
|
||||
"appwrite/php-clamav": "1.0.*",
|
||||
|
||||
"utopia-php/framework": "0.3.*",
|
||||
"utopia-php/framework": "0.3.4",
|
||||
"utopia-php/abuse": "0.2.*",
|
||||
"utopia-php/audit": "0.3.*",
|
||||
"utopia-php/cache": "0.2.*",
|
||||
"utopia-php/cli": "0.6.*",
|
||||
"utopia-php/cli": "0.6.1",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/locale": "0.2.*",
|
||||
"utopia-php/registry": "0.2.*",
|
||||
|
|
32
composer.lock
generated
32
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "001a9336198793f293f83f62df2b7567",
|
||||
"content-hash": "b40a5280315184407b21232e6c607b85",
|
||||
"packages": [
|
||||
{
|
||||
"name": "appwrite/php-clamav",
|
||||
|
@ -1452,21 +1452,21 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/cli",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/cli.git",
|
||||
"reference": "e636c61ac4d0cf7539be332adba9dd9889dc300e"
|
||||
"reference": "0e88da425122f81020e90d575cbe80232f364b68"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/cli/zipball/e636c61ac4d0cf7539be332adba9dd9889dc300e",
|
||||
"reference": "e636c61ac4d0cf7539be332adba9dd9889dc300e",
|
||||
"url": "https://api.github.com/repos/utopia-php/cli/zipball/0e88da425122f81020e90d575cbe80232f364b68",
|
||||
"reference": "0e88da425122f81020e90d575cbe80232f364b68",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1",
|
||||
"utopia-php/framework": "0.3.*"
|
||||
"utopia-php/framework": "0.*.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0"
|
||||
|
@ -1496,7 +1496,7 @@
|
|||
"upf",
|
||||
"utopia"
|
||||
],
|
||||
"time": "2020-06-18T19:28:40+00:00"
|
||||
"time": "2020-06-18T23:00:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/config",
|
||||
|
@ -1596,16 +1596,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/framework",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/framework.git",
|
||||
"reference": "9c3bb4fb69ab85d3d5ba76f334d682845dc4815c"
|
||||
"reference": "dae7464b257663cd250e58244b21781a996134c2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/framework/zipball/9c3bb4fb69ab85d3d5ba76f334d682845dc4815c",
|
||||
"reference": "9c3bb4fb69ab85d3d5ba76f334d682845dc4815c",
|
||||
"url": "https://api.github.com/repos/utopia-php/framework/zipball/dae7464b257663cd250e58244b21781a996134c2",
|
||||
"reference": "dae7464b257663cd250e58244b21781a996134c2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1636,7 +1636,7 @@
|
|||
"php",
|
||||
"upf"
|
||||
],
|
||||
"time": "2020-06-18T19:23:47+00:00"
|
||||
"time": "2020-06-18T23:28:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/locale",
|
||||
|
@ -2141,12 +2141,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
|
||||
"reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e"
|
||||
"reference": "5892a510fe31de9c4200e6f9ae30e91dc5cd5a41"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e",
|
||||
"reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/5892a510fe31de9c4200e6f9ae30e91dc5cd5a41",
|
||||
"reference": "5892a510fe31de9c4200e6f9ae30e91dc5cd5a41",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2186,7 +2186,7 @@
|
|||
}
|
||||
],
|
||||
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
|
||||
"time": "2020-02-22T12:28:44+00:00"
|
||||
"time": "2020-06-18T20:57:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/type-resolver",
|
||||
|
|
Loading…
Reference in a new issue