Merge pull request #305 from appwrite/CONFIG-VARS
Added config vars class
This commit is contained in:
commit
ad3e1a79ef
20 changed files with 201 additions and 128 deletions
16
app/app.php
16
app/app.php
|
@ -3,12 +3,13 @@
|
||||||
// Init
|
// Init
|
||||||
require_once __DIR__.'/init.php';
|
require_once __DIR__.'/init.php';
|
||||||
|
|
||||||
global $env, $utopia, $request, $response, $register, $consoleDB, $project, $domain, $version, $service, $protocol, $domainVerification;
|
global $utopia, $request, $response, $register, $consoleDB, $project, $service;
|
||||||
|
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
use Utopia\Request;
|
use Utopia\Request;
|
||||||
use Utopia\View;
|
use Utopia\View;
|
||||||
use Utopia\Exception;
|
use Utopia\Exception;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Domains\Domain;
|
use Utopia\Domains\Domain;
|
||||||
use Appwrite\Auth\Auth;
|
use Appwrite\Auth\Auth;
|
||||||
use Appwrite\Database\Database;
|
use Appwrite\Database\Database;
|
||||||
|
@ -50,7 +51,7 @@ $clients = array_unique(array_merge($clientsConsole, array_map(function ($node)
|
||||||
return false;
|
return false;
|
||||||
}))));
|
}))));
|
||||||
|
|
||||||
$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $roles, $webhook, $audit, $usage, $domain, $clients, &$domainVerification) {
|
$utopia->init(function () use ($utopia, $request, $response, &$user, $project, $roles, $webhook, $audit, $usage, $clients) {
|
||||||
|
|
||||||
$route = $utopia->match($request);
|
$route = $utopia->match($request);
|
||||||
|
|
||||||
|
@ -62,10 +63,10 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
|
||||||
$refDomain = $protocol.'://'.((in_array($origin, $clients))
|
$refDomain = $protocol.'://'.((in_array($origin, $clients))
|
||||||
? $origin : 'localhost') . (!empty($port) ? ':'.$port : '');
|
? $origin : 'localhost') . (!empty($port) ? ':'.$port : '');
|
||||||
|
|
||||||
$selfDomain = new Domain($domain);
|
$selfDomain = new Domain(Config::getParam('domain'));
|
||||||
$endDomain = new Domain($origin);
|
$endDomain = new Domain($origin);
|
||||||
|
|
||||||
$domainVerification = ($selfDomain->getRegisterable() === $endDomain->getRegisterable());
|
Config::setParam('domainVerification', ($selfDomain->getRegisterable() === $endDomain->getRegisterable()));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Security Headers
|
* Security Headers
|
||||||
|
@ -138,7 +139,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
|
||||||
$user = new Document([
|
$user = new Document([
|
||||||
'$id' => 0,
|
'$id' => 0,
|
||||||
'status' => Auth::USER_STATUS_ACTIVATED,
|
'status' => Auth::USER_STATUS_ACTIVATED,
|
||||||
'email' => 'app.'.$project->getId().'@service.'.$domain,
|
'email' => 'app.'.$project->getId().'@service.'.Config::getParam('domain'),
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'name' => $project->getAttribute('name', 'Untitled'),
|
'name' => $project->getAttribute('name', 'Untitled'),
|
||||||
]);
|
]);
|
||||||
|
@ -247,7 +248,10 @@ $utopia->options(function () use ($request, $response) {
|
||||||
->send();
|
->send();
|
||||||
});
|
});
|
||||||
|
|
||||||
$utopia->error(function ($error /* @var $error Exception */) use ($request, $response, $utopia, $project, $env, $version) {
|
$utopia->error(function ($error /* @var $error Exception */) use ($request, $response, $utopia, $project) {
|
||||||
|
$env = Config::getParam('env');
|
||||||
|
$version = Config::getParam('version');
|
||||||
|
|
||||||
switch ($error->getCode()) {
|
switch ($error->getCode()) {
|
||||||
case 400: // Error allowed publicly
|
case 400: // Error allowed publicly
|
||||||
case 401: // Error allowed publicly
|
case 401: // Error allowed publicly
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $providers, $request;
|
global $request;
|
||||||
|
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Appwrite\Database\Database;
|
use Appwrite\Database\Database;
|
||||||
|
|
||||||
|
$providers = Config::getParam('providers');
|
||||||
|
|
||||||
$collections = [
|
$collections = [
|
||||||
'console' => [
|
'console' => [
|
||||||
'$id' => 'console',
|
'$id' => 'console',
|
||||||
|
@ -1189,15 +1192,15 @@ $collections = [
|
||||||
/*
|
/*
|
||||||
* Add enabled OAuth2 providers to default data rules
|
* Add enabled OAuth2 providers to default data rules
|
||||||
*/
|
*/
|
||||||
foreach ($providers as $key => $provider) {
|
foreach ($providers as $index => $provider) {
|
||||||
if (!$provider['enabled']) {
|
if (!$provider['enabled']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [
|
$collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [
|
||||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||||
'label' => 'OAuth2 '.ucfirst($key).' ID',
|
'label' => 'OAuth2 '.ucfirst($index).' ID',
|
||||||
'key' => 'usersOauth2'.ucfirst($key).'Appid',
|
'key' => 'usersOauth2'.ucfirst($index).'Appid',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
@ -1206,8 +1209,8 @@ foreach ($providers as $key => $provider) {
|
||||||
|
|
||||||
$collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [
|
$collections[Database::SYSTEM_COLLECTION_PROJECTS]['rules'][] = [
|
||||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||||
'label' => 'OAuth2 '.ucfirst($key).' Secret',
|
'label' => 'OAuth2 '.ucfirst($index).' Secret',
|
||||||
'key' => 'usersOauth2'.ucfirst($key).'Secret',
|
'key' => 'usersOauth2'.ucfirst($index).'Secret',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
@ -1216,8 +1219,8 @@ foreach ($providers as $key => $provider) {
|
||||||
|
|
||||||
$collections[Database::SYSTEM_COLLECTION_USERS]['rules'][] = [
|
$collections[Database::SYSTEM_COLLECTION_USERS]['rules'][] = [
|
||||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||||
'label' => 'OAuth2 '.ucfirst($key).' ID',
|
'label' => 'OAuth2 '.ucfirst($index).' ID',
|
||||||
'key' => 'oauth2'.ucfirst($key),
|
'key' => 'oauth2'.ucfirst($index),
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
@ -1226,8 +1229,8 @@ foreach ($providers as $key => $provider) {
|
||||||
|
|
||||||
$collections[Database::SYSTEM_COLLECTION_USERS]['rules'][] = [
|
$collections[Database::SYSTEM_COLLECTION_USERS]['rules'][] = [
|
||||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||||
'label' => 'OAuth2 '.ucfirst($key).' Access Token',
|
'label' => 'OAuth2 '.ucfirst($index).' Access Token',
|
||||||
'key' => 'oauth2'.ucfirst($key).'AccessToken',
|
'key' => 'oauth2'.ucfirst($index).'AccessToken',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $utopia, $register, $request, $response, $user, $audit,
|
global $utopia, $register, $request, $response, $user, $audit,
|
||||||
$webhook, $project, $domain, $projectDB, $providers, $clients, $protocol;
|
$webhook, $project, $projectDB, $clients;
|
||||||
|
|
||||||
use Utopia\Exception;
|
use Utopia\Exception;
|
||||||
use Utopia\Response;
|
use Utopia\Response;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Validator\Assoc;
|
use Utopia\Validator\Assoc;
|
||||||
use Utopia\Validator\Text;
|
use Utopia\Validator\Text;
|
||||||
use Utopia\Validator\Email;
|
use Utopia\Validator\Email;
|
||||||
|
@ -30,8 +31,8 @@ include_once __DIR__ . '/../shared/api.php';
|
||||||
|
|
||||||
$oauth2Keys = [];
|
$oauth2Keys = [];
|
||||||
|
|
||||||
$utopia->init(function() use ($providers, &$oauth2Keys) {
|
$utopia->init(function() use (&$oauth2Keys) {
|
||||||
foreach ($providers as $key => $provider) {
|
foreach (Config::getParam('providers') as $key => $provider) {
|
||||||
if (!$provider['enabled']) {
|
if (!$provider['enabled']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +156,8 @@ $utopia->post('/v1/account/sessions')
|
||||||
->param('email', '', function () { return new Email(); }, 'User email.')
|
->param('email', '', function () { return new Email(); }, 'User email.')
|
||||||
->param('password', '', function () { return new Password(); }, 'User password.')
|
->param('password', '', function () { return new Password(); }, 'User password.')
|
||||||
->action(
|
->action(
|
||||||
function ($email, $password) use ($response, $request, $projectDB, $audit, $webhook, $protocol, $domainVerification) {
|
function ($email, $password) use ($response, $request, $projectDB, $audit, $webhook) {
|
||||||
|
$protocol = Config::getParam('protocol');
|
||||||
$profile = $projectDB->getCollection([ // Get user by email address
|
$profile = $projectDB->getCollection([ // Get user by email address
|
||||||
'limit' => 1,
|
'limit' => 1,
|
||||||
'first' => true,
|
'first' => true,
|
||||||
|
@ -216,7 +218,7 @@ $utopia->post('/v1/account/sessions')
|
||||||
->setParam('resource', 'users/'.$profile->getId())
|
->setParam('resource', 'users/'.$profile->getId())
|
||||||
;
|
;
|
||||||
|
|
||||||
if(!$domainVerification) {
|
if(!Config::getParam('domainVerification')) {
|
||||||
$response
|
$response
|
||||||
->addHeader('X-Fallback-Cookies', json_encode([Auth::$cookieName => Auth::encodeSession($profile->getId(), $secret)]))
|
->addHeader('X-Fallback-Cookies', json_encode([Auth::$cookieName => Auth::encodeSession($profile->getId(), $secret)]))
|
||||||
;
|
;
|
||||||
|
@ -244,11 +246,12 @@ $utopia->get('/v1/account/sessions/oauth2/:provider')
|
||||||
->label('sdk.location', true)
|
->label('sdk.location', true)
|
||||||
->label('abuse-limit', 50)
|
->label('abuse-limit', 50)
|
||||||
->label('abuse-key', 'ip:{ip}')
|
->label('abuse-key', 'ip:{ip}')
|
||||||
->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth2 Provider. Currently, supported providers are: ' . implode(', ', array_keys(array_filter($providers, function($node) {return (!$node['mock']);}))).'.')
|
->param('provider', '', function () { return new WhiteList(array_keys(Config::getParam('providers'))); }, 'OAuth2 Provider. Currently, supported providers are: ' . implode(', ', array_keys(array_filter(Config::getParam('providers'), function($node) {return (!$node['mock']);}))).'.')
|
||||||
->param('success', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt.')
|
->param('success', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a successful login attempt.')
|
||||||
->param('failure', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt.')
|
->param('failure', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt.')
|
||||||
->action(
|
->action(
|
||||||
function ($provider, $success, $failure) use ($response, $request, $project, $protocol) {
|
function ($provider, $success, $failure) use ($response, $request, $project) {
|
||||||
|
$protocol = Config::getParam('protocol');
|
||||||
$callback = $protocol.'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId();
|
$callback = $protocol.'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId();
|
||||||
$appId = $project->getAttribute('usersOauth2'.ucfirst($provider).'Appid', '');
|
$appId = $project->getAttribute('usersOauth2'.ucfirst($provider).'Appid', '');
|
||||||
$appSecret = $project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}');
|
$appSecret = $project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}');
|
||||||
|
@ -282,11 +285,13 @@ $utopia->get('/v1/account/sessions/oauth2/callback/:provider/:projectId')
|
||||||
->label('scope', 'public')
|
->label('scope', 'public')
|
||||||
->label('docs', false)
|
->label('docs', false)
|
||||||
->param('projectId', '', function () { return new Text(1024); }, 'Project unique ID.')
|
->param('projectId', '', function () { return new Text(1024); }, 'Project unique ID.')
|
||||||
->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth2 provider.')
|
->param('provider', '', function () { return new WhiteList(array_keys(Config::getParam('providers'))); }, 'OAuth2 provider.')
|
||||||
->param('code', '', function () { return new Text(1024); }, 'OAuth2 code.')
|
->param('code', '', function () { return new Text(1024); }, 'OAuth2 code.')
|
||||||
->param('state', '', function () { return new Text(2048); }, 'Login state params.', true)
|
->param('state', '', function () { return new Text(2048); }, 'Login state params.', true)
|
||||||
->action(
|
->action(
|
||||||
function ($projectId, $provider, $code, $state) use ($response, $request, $domain, $protocol) {
|
function ($projectId, $provider, $code, $state) use ($response) {
|
||||||
|
$domain = Config::getParam('domain');
|
||||||
|
$protocol = Config::getParam('protocol');
|
||||||
$response->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?'
|
$response->redirect($protocol.'://'.$domain.'/v1/account/sessions/oauth2/'.$provider.'/redirect?'
|
||||||
.http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state]));
|
.http_build_query(['project' => $projectId, 'code' => $code, 'state' => $state]));
|
||||||
}
|
}
|
||||||
|
@ -300,11 +305,12 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||||
->label('abuse-limit', 50)
|
->label('abuse-limit', 50)
|
||||||
->label('abuse-key', 'ip:{ip}')
|
->label('abuse-key', 'ip:{ip}')
|
||||||
->label('docs', false)
|
->label('docs', false)
|
||||||
->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'OAuth2 provider.')
|
->param('provider', '', function () { return new WhiteList(array_keys(Config::getParam('providers'))); }, 'OAuth2 provider.')
|
||||||
->param('code', '', function () { return new Text(1024); }, 'OAuth2 code.')
|
->param('code', '', function () { return new Text(1024); }, 'OAuth2 code.')
|
||||||
->param('state', '', function () { return new Text(2048); }, 'OAuth2 state params.', true)
|
->param('state', '', function () { return new Text(2048); }, 'OAuth2 state params.', true)
|
||||||
->action(
|
->action(
|
||||||
function ($provider, $code, $state) use ($response, $request, $user, $projectDB, $project, $audit, $protocol, $domainVerification) {
|
function ($provider, $code, $state) use ($response, $request, $user, $projectDB, $project, $audit) {
|
||||||
|
$protocol = Config::getParam('protocol');
|
||||||
$callback = $protocol.'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId();
|
$callback = $protocol.'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId();
|
||||||
$defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => ''];
|
$defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => ''];
|
||||||
$validateURL = new URL();
|
$validateURL = new URL();
|
||||||
|
@ -457,7 +463,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||||
->setParam('data', ['provider' => $provider])
|
->setParam('data', ['provider' => $provider])
|
||||||
;
|
;
|
||||||
|
|
||||||
if(!$domainVerification) {
|
if(!Config::getParam('domainVerification')) {
|
||||||
$response
|
$response
|
||||||
->addHeader('X-Fallback-Cookies', json_encode([Auth::$cookieName => Auth::encodeSession($user->getId(), $secret)]))
|
->addHeader('X-Fallback-Cookies', json_encode([Auth::$cookieName => Auth::encodeSession($user->getId(), $secret)]))
|
||||||
;
|
;
|
||||||
|
@ -832,7 +838,8 @@ $utopia->delete('/v1/account')
|
||||||
->label('sdk.method', 'delete')
|
->label('sdk.method', 'delete')
|
||||||
->label('sdk.description', '/docs/references/account/delete.md')
|
->label('sdk.description', '/docs/references/account/delete.md')
|
||||||
->action(
|
->action(
|
||||||
function () use ($response, $user, $projectDB, $audit, $webhook, $protocol, $domainVerification) {
|
function () use ($response, $user, $projectDB, $audit, $webhook) {
|
||||||
|
$protocol = Config::getParam('protocol');
|
||||||
$user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [
|
$user = $projectDB->updateDocument(array_merge($user->getArrayCopy(), [
|
||||||
'status' => Auth::USER_STATUS_BLOCKED,
|
'status' => Auth::USER_STATUS_BLOCKED,
|
||||||
]));
|
]));
|
||||||
|
@ -863,7 +870,7 @@ $utopia->delete('/v1/account')
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
if(!$domainVerification) {
|
if(!Config::getParam('domainVerification')) {
|
||||||
$response
|
$response
|
||||||
->addHeader('X-Fallback-Cookies', json_encode([]))
|
->addHeader('X-Fallback-Cookies', json_encode([]))
|
||||||
;
|
;
|
||||||
|
@ -888,7 +895,8 @@ $utopia->delete('/v1/account/sessions/:sessionId')
|
||||||
->label('abuse-limit', 100)
|
->label('abuse-limit', 100)
|
||||||
->param('sessionId', null, function () { return new UID(); }, 'Session unique ID. Use the string \'current\' to delete the current device session.')
|
->param('sessionId', null, function () { return new UID(); }, 'Session unique ID. Use the string \'current\' to delete the current device session.')
|
||||||
->action(
|
->action(
|
||||||
function ($sessionId) use ($response, $user, $projectDB, $webhook, $audit, $protocol, $domainVerification) {
|
function ($sessionId) use ($response, $user, $projectDB, $webhook, $audit) {
|
||||||
|
$protocol = Config::getParam('protocol');
|
||||||
$sessionId = ($sessionId === 'current')
|
$sessionId = ($sessionId === 'current')
|
||||||
? Auth::tokenVerify($user->getAttribute('tokens'), Auth::TOKEN_TYPE_LOGIN, Auth::$secret)
|
? Auth::tokenVerify($user->getAttribute('tokens'), Auth::TOKEN_TYPE_LOGIN, Auth::$secret)
|
||||||
: $sessionId;
|
: $sessionId;
|
||||||
|
@ -914,7 +922,7 @@ $utopia->delete('/v1/account/sessions/:sessionId')
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
if(!$domainVerification) {
|
if(!Config::getParam('domainVerification')) {
|
||||||
$response
|
$response
|
||||||
->addHeader('X-Fallback-Cookies', json_encode([]))
|
->addHeader('X-Fallback-Cookies', json_encode([]))
|
||||||
;
|
;
|
||||||
|
@ -945,7 +953,8 @@ $utopia->delete('/v1/account/sessions')
|
||||||
->label('sdk.description', '/docs/references/account/delete-sessions.md')
|
->label('sdk.description', '/docs/references/account/delete-sessions.md')
|
||||||
->label('abuse-limit', 100)
|
->label('abuse-limit', 100)
|
||||||
->action(
|
->action(
|
||||||
function () use ($response, $user, $projectDB, $audit, $webhook, $protocol, $domainVerification) {
|
function () use ($response, $user, $projectDB, $audit, $webhook) {
|
||||||
|
$protocol = Config::getParam('protocol');
|
||||||
$tokens = $user->getAttribute('tokens', []);
|
$tokens = $user->getAttribute('tokens', []);
|
||||||
|
|
||||||
foreach ($tokens as $token) { /* @var $token Document */
|
foreach ($tokens as $token) { /* @var $token Document */
|
||||||
|
@ -966,7 +975,7 @@ $utopia->delete('/v1/account/sessions')
|
||||||
])
|
])
|
||||||
;
|
;
|
||||||
|
|
||||||
if(!$domainVerification) {
|
if(!Config::getParam('domainVerification')) {
|
||||||
$response
|
$response
|
||||||
->addHeader('X-Fallback-Cookies', json_encode([]))
|
->addHeader('X-Fallback-Cookies', json_encode([]))
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $utopia, $request, $response, $version;
|
global $utopia, $request, $response;
|
||||||
|
|
||||||
use Utopia\Exception;
|
use Utopia\Exception;
|
||||||
use Utopia\Validator\Text;
|
use Utopia\Validator\Text;
|
||||||
|
@ -14,6 +14,7 @@ use BaconQrCode\Renderer\ImageRenderer;
|
||||||
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
|
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
|
||||||
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
|
||||||
use BaconQrCode\Writer;
|
use BaconQrCode\Writer;
|
||||||
|
use Utopia\Config\Config;
|
||||||
|
|
||||||
include_once __DIR__ . '/../shared/api.php';
|
include_once __DIR__ . '/../shared/api.php';
|
||||||
|
|
||||||
|
@ -206,7 +207,7 @@ $utopia->get('/v1/avatars/favicon')
|
||||||
->label('sdk.method', 'getFavicon')
|
->label('sdk.method', 'getFavicon')
|
||||||
->label('sdk.description', '/docs/references/avatars/get-favicon.md')
|
->label('sdk.description', '/docs/references/avatars/get-favicon.md')
|
||||||
->action(
|
->action(
|
||||||
function ($url) use ($response, $request, $version) {
|
function ($url) use ($response, $request) {
|
||||||
$width = 56;
|
$width = 56;
|
||||||
$height = 56;
|
$height = 56;
|
||||||
$quality = 80;
|
$quality = 80;
|
||||||
|
@ -238,7 +239,7 @@ $utopia->get('/v1/avatars/favicon')
|
||||||
CURLOPT_MAXREDIRS => 3,
|
CURLOPT_MAXREDIRS => 3,
|
||||||
CURLOPT_URL => $url,
|
CURLOPT_URL => $url,
|
||||||
CURLOPT_USERAGENT => sprintf(APP_USERAGENT,
|
CURLOPT_USERAGENT => sprintf(APP_USERAGENT,
|
||||||
$version,
|
Config::getParam('version'),
|
||||||
$request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)
|
$request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $utopia, $request, $response, $register, $user, $consoleDB, $projectDB, $providers;
|
global $utopia, $request, $response, $register, $user, $consoleDB, $projectDB;
|
||||||
|
|
||||||
use Utopia\Exception;
|
use Utopia\Exception;
|
||||||
use Utopia\Response;
|
use Utopia\Response;
|
||||||
|
@ -10,6 +10,7 @@ use Utopia\Validator\Text;
|
||||||
use Utopia\Validator\WhiteList;
|
use Utopia\Validator\WhiteList;
|
||||||
use Utopia\Validator\Range;
|
use Utopia\Validator\Range;
|
||||||
use Utopia\Validator\URL;
|
use Utopia\Validator\URL;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Domains\Domain;
|
use Utopia\Domains\Domain;
|
||||||
use Appwrite\Auth\Auth;
|
use Appwrite\Auth\Auth;
|
||||||
use Appwrite\Task\Validator\Cron;
|
use Appwrite\Task\Validator\Cron;
|
||||||
|
@ -92,7 +93,7 @@ $utopia->get('/v1/projects')
|
||||||
->label('sdk.namespace', 'projects')
|
->label('sdk.namespace', 'projects')
|
||||||
->label('sdk.method', 'list')
|
->label('sdk.method', 'list')
|
||||||
->action(
|
->action(
|
||||||
function () use ($request, $response, $providers, $consoleDB) {
|
function () use ($request, $response, $consoleDB) {
|
||||||
$results = $consoleDB->getCollection([
|
$results = $consoleDB->getCollection([
|
||||||
'limit' => 20,
|
'limit' => 20,
|
||||||
'offset' => 0,
|
'offset' => 0,
|
||||||
|
@ -105,7 +106,7 @@ $utopia->get('/v1/projects')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
foreach ($results as $project) {
|
foreach ($results as $project) {
|
||||||
foreach ($providers as $provider => $node) {
|
foreach (Config::getParam('providers') as $provider => $node) {
|
||||||
$secret = json_decode($project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}'), true);
|
$secret = json_decode($project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}'), true);
|
||||||
|
|
||||||
if (!empty($secret) && isset($secret['version'])) {
|
if (!empty($secret) && isset($secret['version'])) {
|
||||||
|
@ -126,14 +127,14 @@ $utopia->get('/v1/projects/:projectId')
|
||||||
->label('sdk.method', 'get')
|
->label('sdk.method', 'get')
|
||||||
->param('projectId', '', function () { return new UID(); }, 'Project unique ID.')
|
->param('projectId', '', function () { return new UID(); }, 'Project unique ID.')
|
||||||
->action(
|
->action(
|
||||||
function ($projectId) use ($request, $response, $providers, $consoleDB) {
|
function ($projectId) use ($request, $response, $consoleDB) {
|
||||||
$project = $consoleDB->getDocument($projectId);
|
$project = $consoleDB->getDocument($projectId);
|
||||||
|
|
||||||
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
|
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
|
||||||
throw new Exception('Project not found', 404);
|
throw new Exception('Project not found', 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($providers as $provider => $node) {
|
foreach (Config::getParam('providers') as $provider => $node) {
|
||||||
$secret = json_decode($project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}'), true);
|
$secret = json_decode($project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}'), true);
|
||||||
|
|
||||||
if (!empty($secret) && isset($secret['version'])) {
|
if (!empty($secret) && isset($secret['version'])) {
|
||||||
|
@ -331,7 +332,7 @@ $utopia->patch('/v1/projects/:projectId/oauth2')
|
||||||
->label('sdk.namespace', 'projects')
|
->label('sdk.namespace', 'projects')
|
||||||
->label('sdk.method', 'updateOAuth2')
|
->label('sdk.method', 'updateOAuth2')
|
||||||
->param('projectId', '', function () { return new UID(); }, 'Project unique ID.')
|
->param('projectId', '', function () { return new UID(); }, 'Project unique ID.')
|
||||||
->param('provider', '', function () use ($providers) { return new WhiteList(array_keys($providers)); }, 'Provider Name', false)
|
->param('provider', '', function () { return new WhiteList(array_keys(Config::getParam('providers'))); }, 'Provider Name', false)
|
||||||
->param('appId', '', function () { return new Text(256); }, 'Provider app ID.', true)
|
->param('appId', '', function () { return new Text(256); }, 'Provider app ID.', true)
|
||||||
->param('secret', '', function () { return new text(256); }, 'Provider secret key.', true)
|
->param('secret', '', function () { return new text(256); }, 'Provider secret key.', true)
|
||||||
->action(
|
->action(
|
||||||
|
@ -1201,8 +1202,9 @@ $utopia->post('/v1/projects/:projectId/domains')
|
||||||
->param('projectId', null, function () { return new UID(); }, 'Project unique ID.')
|
->param('projectId', null, function () { return new UID(); }, 'Project unique ID.')
|
||||||
->param('domain', null, function () { return new DomainValidator(); }, 'Domain name.')
|
->param('domain', null, function () { return new DomainValidator(); }, 'Domain name.')
|
||||||
->action(
|
->action(
|
||||||
function ($projectId, $domain) use ($request, $response, $consoleDB) {
|
function ($projectId) use ($request, $response, $consoleDB) {
|
||||||
$project = $consoleDB->getDocument($projectId);
|
$project = $consoleDB->getDocument($projectId);
|
||||||
|
$domain = Config::getParam('domain');
|
||||||
|
|
||||||
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
|
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
|
||||||
throw new Exception('Project not found', 404);
|
throw new Exception('Project not found', 404);
|
||||||
|
@ -1283,7 +1285,7 @@ $utopia->get('/v1/projects/:projectId/domains/:domainId')
|
||||||
->param('projectId', null, function () { return new UID(); }, 'Project unique ID.')
|
->param('projectId', null, function () { return new UID(); }, 'Project unique ID.')
|
||||||
->param('domainId', null, function () { return new UID(); }, 'Domain unique ID.')
|
->param('domainId', null, function () { return new UID(); }, 'Domain unique ID.')
|
||||||
->action(
|
->action(
|
||||||
function ($projectId, $domainId) use ($request, $response, $consoleDB) {
|
function ($projectId, $domainId) use ($response, $consoleDB) {
|
||||||
$project = $consoleDB->getDocument($projectId);
|
$project = $consoleDB->getDocument($projectId);
|
||||||
|
|
||||||
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
|
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $utopia, $request, $response, $register, $user, $audit, $usage, $project, $projectDB, $version;
|
global $utopia, $request, $response, $register, $user, $audit, $usage, $project, $projectDB;
|
||||||
|
|
||||||
use Utopia\Exception;
|
use Utopia\Exception;
|
||||||
use Utopia\Response;
|
use Utopia\Response;
|
||||||
|
@ -338,7 +338,7 @@ $utopia->get('/v1/storage/files/:fileId/preview')
|
||||||
//->param('storage', 'local', function () {return new WhiteList(array('local'));}, 'Selected storage device. defaults to local')
|
//->param('storage', 'local', function () {return new WhiteList(array('local'));}, 'Selected storage device. defaults to local')
|
||||||
//->param('token', '', function () {return new Text(128);}, 'Preview token', true)
|
//->param('token', '', function () {return new Text(128);}, 'Preview token', true)
|
||||||
->action(
|
->action(
|
||||||
function ($fileId, $width, $height, $quality, $background, $output) use ($request, $response, $projectDB, $project, $inputs, $outputs, $fileLogos, $version) {
|
function ($fileId, $width, $height, $quality, $background, $output) use ($request, $response, $projectDB, $project, $inputs, $outputs, $fileLogos) {
|
||||||
$storage = 'local';
|
$storage = 'local';
|
||||||
|
|
||||||
if (!extension_loaded('imagick')) {
|
if (!extension_loaded('imagick')) {
|
||||||
|
@ -354,7 +354,7 @@ $utopia->get('/v1/storage/files/:fileId/preview')
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = date('D, d M Y H:i:s', time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache
|
$date = date('D, d M Y H:i:s', time() + (60 * 60 * 24 * 45)).' GMT'; // 45 days cache
|
||||||
$key = md5($version.$fileId.$width.$height.$quality.$background.$storage.$output);
|
$key = md5($fileId.$width.$height.$quality.$background.$storage.$output);
|
||||||
|
|
||||||
$file = $projectDB->getDocument($fileId);
|
$file = $projectDB->getDocument($fileId);
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ $utopia->get('/v1/storage/files/:fileId/preview')
|
||||||
$cipher = null;
|
$cipher = null;
|
||||||
$background = (empty($background)) ? 'eceff1' : $background;
|
$background = (empty($background)) ? 'eceff1' : $background;
|
||||||
$type = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
$type = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||||
$key = md5($version.$path.$width.$height.$quality.$background.$storage.$output);
|
$key = md5($path.$width.$height.$quality.$background.$storage.$output);
|
||||||
}
|
}
|
||||||
|
|
||||||
$compressor = new GZIP();
|
$compressor = new GZIP();
|
||||||
|
|
|
@ -4,6 +4,7 @@ global $utopia, $register, $request, $response, $projectDB, $project, $user, $au
|
||||||
|
|
||||||
use Utopia\Exception;
|
use Utopia\Exception;
|
||||||
use Utopia\Response;
|
use Utopia\Response;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Validator\Email;
|
use Utopia\Validator\Email;
|
||||||
use Utopia\Validator\Text;
|
use Utopia\Validator\Text;
|
||||||
use Utopia\Validator\Host;
|
use Utopia\Validator\Host;
|
||||||
|
@ -431,7 +432,8 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
|
||||||
->param('userId', '', function () { return new UID(); }, 'User unique ID.')
|
->param('userId', '', function () { return new UID(); }, 'User unique ID.')
|
||||||
->param('secret', '', function () { return new Text(256); }, 'Secret key.')
|
->param('secret', '', function () { return new Text(256); }, 'Secret key.')
|
||||||
->action(
|
->action(
|
||||||
function ($teamId, $inviteId, $userId, $secret) use ($response, $request, $user, $audit, $projectDB, $protocol, $domainVerification) {
|
function ($teamId, $inviteId, $userId, $secret) use ($response, $request, $user, $audit, $projectDB) {
|
||||||
|
$protocol = Config::getParam('protocol');
|
||||||
$membership = $projectDB->getDocument($inviteId);
|
$membership = $projectDB->getDocument($inviteId);
|
||||||
|
|
||||||
if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) {
|
if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) {
|
||||||
|
@ -525,7 +527,7 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
|
||||||
->setParam('resource', 'teams/'.$teamId)
|
->setParam('resource', 'teams/'.$teamId)
|
||||||
;
|
;
|
||||||
|
|
||||||
if(!$domainVerification) {
|
if(!Config::getParam('domainVerification')) {
|
||||||
$response
|
$response
|
||||||
->addHeader('X-Fallback-Cookies', json_encode([Auth::$cookieName => Auth::encodeSession($user->getId(), $secret)]))
|
->addHeader('X-Fallback-Cookies', json_encode([Auth::$cookieName => Auth::encodeSession($user->getId(), $secret)]))
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $utopia, $response, $projectDB, $providers;
|
global $utopia, $response, $projectDB;
|
||||||
|
|
||||||
use Utopia\Exception;
|
use Utopia\Exception;
|
||||||
use Utopia\Response;
|
use Utopia\Response;
|
||||||
|
@ -11,6 +11,7 @@ use Utopia\Validator\Text;
|
||||||
use Utopia\Validator\Range;
|
use Utopia\Validator\Range;
|
||||||
use Utopia\Audit\Audit;
|
use Utopia\Audit\Audit;
|
||||||
use Utopia\Audit\Adapters\MySQL as AuditAdapter;
|
use Utopia\Audit\Adapters\MySQL as AuditAdapter;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Locale\Locale;
|
use Utopia\Locale\Locale;
|
||||||
use Appwrite\Auth\Auth;
|
use Appwrite\Auth\Auth;
|
||||||
use Appwrite\Auth\Validator\Password;
|
use Appwrite\Auth\Validator\Password;
|
||||||
|
@ -33,7 +34,7 @@ $utopia->post('/v1/users')
|
||||||
->param('password', '', function () { return new Password(); }, 'User password.')
|
->param('password', '', function () { return new Password(); }, 'User password.')
|
||||||
->param('name', '', function () { return new Text(100); }, 'User name.', true)
|
->param('name', '', function () { return new Text(100); }, 'User name.', true)
|
||||||
->action(
|
->action(
|
||||||
function ($email, $password, $name) use ($response, $register, $projectDB, $providers) {
|
function ($email, $password, $name) use ($response, $projectDB) {
|
||||||
$profile = $projectDB->getCollection([ // Get user by email address
|
$profile = $projectDB->getCollection([ // Get user by email address
|
||||||
'limit' => 1,
|
'limit' => 1,
|
||||||
'first' => true,
|
'first' => true,
|
||||||
|
@ -69,7 +70,7 @@ $utopia->post('/v1/users')
|
||||||
|
|
||||||
$oauth2Keys = [];
|
$oauth2Keys = [];
|
||||||
|
|
||||||
foreach ($providers as $key => $provider) {
|
foreach (Config::getParam('providers') as $key => $provider) {
|
||||||
if (!$provider['enabled']) {
|
if (!$provider['enabled']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +104,7 @@ $utopia->get('/v1/users')
|
||||||
->param('offset', 0, function () { return new Range(0, 2000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
->param('offset', 0, function () { return new Range(0, 2000); }, 'Results offset. The default value is 0. Use this param to manage pagination.', true)
|
||||||
->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true)
|
->param('orderType', 'ASC', function () { return new WhiteList(['ASC', 'DESC']); }, 'Order result by ASC or DESC order.', true)
|
||||||
->action(
|
->action(
|
||||||
function ($search, $limit, $offset, $orderType) use ($response, $projectDB, $providers) {
|
function ($search, $limit, $offset, $orderType) use ($response, $projectDB) {
|
||||||
$results = $projectDB->getCollection([
|
$results = $projectDB->getCollection([
|
||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
'offset' => $offset,
|
'offset' => $offset,
|
||||||
|
@ -118,7 +119,7 @@ $utopia->get('/v1/users')
|
||||||
|
|
||||||
$oauth2Keys = [];
|
$oauth2Keys = [];
|
||||||
|
|
||||||
foreach ($providers as $key => $provider) {
|
foreach (Config::getParam('providers') as $key => $provider) {
|
||||||
if (!$provider['enabled']) {
|
if (!$provider['enabled']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +155,7 @@ $utopia->get('/v1/users/:userId')
|
||||||
->label('sdk.description', '/docs/references/users/get-user.md')
|
->label('sdk.description', '/docs/references/users/get-user.md')
|
||||||
->param('userId', '', function () { return new UID(); }, 'User unique ID.')
|
->param('userId', '', function () { return new UID(); }, 'User unique ID.')
|
||||||
->action(
|
->action(
|
||||||
function ($userId) use ($response, $projectDB, $providers) {
|
function ($userId) use ($response, $projectDB) {
|
||||||
$user = $projectDB->getDocument($userId);
|
$user = $projectDB->getDocument($userId);
|
||||||
|
|
||||||
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
|
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
|
||||||
|
@ -163,7 +164,7 @@ $utopia->get('/v1/users/:userId')
|
||||||
|
|
||||||
$oauth2Keys = [];
|
$oauth2Keys = [];
|
||||||
|
|
||||||
foreach ($providers as $key => $provider) {
|
foreach (Config::getParam('providers') as $key => $provider) {
|
||||||
if (!$provider['enabled']) {
|
if (!$provider['enabled']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +353,7 @@ $utopia->patch('/v1/users/:userId/status')
|
||||||
->param('userId', '', function () { return new UID(); }, 'User unique ID.')
|
->param('userId', '', function () { return new UID(); }, 'User unique ID.')
|
||||||
->param('status', '', function () { return new WhiteList([Auth::USER_STATUS_ACTIVATED, Auth::USER_STATUS_BLOCKED, Auth::USER_STATUS_UNACTIVATED]); }, 'User Status code. To activate the user pass '.Auth::USER_STATUS_ACTIVATED.', to block the user pass '.Auth::USER_STATUS_BLOCKED.' and for disabling the user pass '.Auth::USER_STATUS_UNACTIVATED)
|
->param('status', '', function () { return new WhiteList([Auth::USER_STATUS_ACTIVATED, Auth::USER_STATUS_BLOCKED, Auth::USER_STATUS_UNACTIVATED]); }, 'User Status code. To activate the user pass '.Auth::USER_STATUS_ACTIVATED.', to block the user pass '.Auth::USER_STATUS_BLOCKED.' and for disabling the user pass '.Auth::USER_STATUS_UNACTIVATED)
|
||||||
->action(
|
->action(
|
||||||
function ($userId, $status) use ($response, $projectDB, $providers) {
|
function ($userId, $status) use ($response, $projectDB) {
|
||||||
$user = $projectDB->getDocument($userId);
|
$user = $projectDB->getDocument($userId);
|
||||||
|
|
||||||
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
|
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
|
||||||
|
@ -369,7 +370,7 @@ $utopia->patch('/v1/users/:userId/status')
|
||||||
|
|
||||||
$oauth2Keys = [];
|
$oauth2Keys = [];
|
||||||
|
|
||||||
foreach ($providers as $key => $provider) {
|
foreach (Config::getParam('providers') as $key => $provider) {
|
||||||
if (!$provider['enabled']) {
|
if (!$provider['enabled']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +401,7 @@ $utopia->patch('/v1/users/:userId/prefs')
|
||||||
->param('userId', '', function () { return new UID(); }, 'User unique ID.')
|
->param('userId', '', function () { return new UID(); }, 'User unique ID.')
|
||||||
->param('prefs', '', function () { return new Assoc();}, 'Prefs key-value JSON object.')
|
->param('prefs', '', function () { return new Assoc();}, 'Prefs key-value JSON object.')
|
||||||
->action(
|
->action(
|
||||||
function ($userId, $prefs) use ($response, $projectDB, $providers) {
|
function ($userId, $prefs) use ($response, $projectDB) {
|
||||||
$user = $projectDB->getDocument($userId);
|
$user = $projectDB->getDocument($userId);
|
||||||
|
|
||||||
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
|
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Utopia\View;
|
use Utopia\View;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Locale\Locale;
|
use Utopia\Locale\Locale;
|
||||||
|
|
||||||
global $protocol;
|
|
||||||
|
|
||||||
Locale::$exceptions = false;
|
Locale::$exceptions = false;
|
||||||
|
|
||||||
$roles = [
|
$roles = [
|
||||||
|
@ -22,7 +21,7 @@ if (!empty($request->getQuery('version', ''))) {
|
||||||
|
|
||||||
$layout
|
$layout
|
||||||
->setParam('title', APP_NAME)
|
->setParam('title', APP_NAME)
|
||||||
->setParam('protocol', $protocol)
|
->setParam('protocol', Config::getParam('protocol'))
|
||||||
->setParam('domain', $domain)
|
->setParam('domain', $domain)
|
||||||
->setParam('home', $request->getServer('_APP_HOME'))
|
->setParam('home', $request->getServer('_APP_HOME'))
|
||||||
->setParam('setup', $request->getServer('_APP_SETUP'))
|
->setParam('setup', $request->getServer('_APP_SETUP'))
|
||||||
|
@ -32,9 +31,9 @@ $layout
|
||||||
->setParam('env', $utopia->getEnv())
|
->setParam('env', $utopia->getEnv())
|
||||||
;
|
;
|
||||||
|
|
||||||
$utopia->shutdown(function () use ($utopia, $response, $request, $layout, $version, $env) {
|
$utopia->shutdown(function () use ($utopia, $response, $request, $layout) {
|
||||||
$time = (60 * 60 * 24 * 45); // 45 days cache
|
$time = (60 * 60 * 24 * 45); // 45 days cache
|
||||||
$isDev = (\Utopia\App::ENV_TYPE_DEVELOPMENT == $env);
|
$isDev = (\Utopia\App::ENV_TYPE_DEVELOPMENT == Config::getParam('env'));
|
||||||
|
|
||||||
$response
|
$response
|
||||||
->addHeader('Cache-Control', 'public, max-age='.$time)
|
->addHeader('Cache-Control', 'public, max-age='.$time)
|
||||||
|
@ -44,7 +43,7 @@ $utopia->shutdown(function () use ($utopia, $response, $request, $layout, $versi
|
||||||
$route = $utopia->match($request);
|
$route = $utopia->match($request);
|
||||||
$scope = $route->getLabel('scope', '');
|
$scope = $route->getLabel('scope', '');
|
||||||
$layout
|
$layout
|
||||||
->setParam('version', $version)
|
->setParam('version', Config::getParam('version'))
|
||||||
->setParam('isDev', $isDev)
|
->setParam('isDev', $isDev)
|
||||||
->setParam('class', $scope)
|
->setParam('class', $scope)
|
||||||
;
|
;
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
include_once __DIR__ . '/../shared/web.php';
|
include_once __DIR__ . '/../shared/web.php';
|
||||||
|
|
||||||
global $utopia, $response, $request, $layout, $version, $providers, $projectDB;
|
global $utopia, $response, $request, $layout, $projectDB;
|
||||||
|
|
||||||
use Utopia\View;
|
use Utopia\View;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Domains\Domain;
|
use Utopia\Domains\Domain;
|
||||||
use Appwrite\Database\Database;
|
use Appwrite\Database\Database;
|
||||||
use Appwrite\Database\Validator\UID;
|
use Appwrite\Database\Validator\UID;
|
||||||
|
@ -16,25 +17,18 @@ $utopia->init(function () use ($layout, $utopia) {
|
||||||
;
|
;
|
||||||
});
|
});
|
||||||
|
|
||||||
$utopia->shutdown(function () use ($utopia, $response, $request, $layout, $version) {
|
$utopia->shutdown(function () use ($response, $request, $layout) {
|
||||||
$header = new View(__DIR__.'/../../views/console/comps/header.phtml');
|
$header = new View(__DIR__.'/../../views/console/comps/header.phtml');
|
||||||
$footer = new View(__DIR__.'/../../views/console/comps/footer.phtml');
|
$footer = new View(__DIR__.'/../../views/console/comps/footer.phtml');
|
||||||
|
|
||||||
$footer
|
$footer
|
||||||
->setParam('home', $request->getServer('_APP_HOME', ''))
|
->setParam('home', $request->getServer('_APP_HOME', ''))
|
||||||
->setParam('version', $version)
|
->setParam('version', Config::getParam('version'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$layout
|
$layout
|
||||||
->setParam('header', [$header])
|
->setParam('header', [$header])
|
||||||
->setParam('footer', [$footer])
|
->setParam('footer', [$footer])
|
||||||
->setParam('prefetch', [
|
|
||||||
//'/console/database?version=' . $version,
|
|
||||||
//'/console/storage?version=' . $version,
|
|
||||||
//'/console/users?version=' . $version,
|
|
||||||
//'/console/settings?version=' . $version,
|
|
||||||
//'/console/account?version=' . $version,
|
|
||||||
])
|
|
||||||
;
|
;
|
||||||
|
|
||||||
$response->send($layout->render());
|
$response->send($layout->render());
|
||||||
|
@ -228,10 +222,10 @@ $utopia->get('/console/users')
|
||||||
->desc('Platform console project settings')
|
->desc('Platform console project settings')
|
||||||
->label('permission', 'public')
|
->label('permission', 'public')
|
||||||
->label('scope', 'console')
|
->label('scope', 'console')
|
||||||
->action(function () use ($layout, $providers) {
|
->action(function () use ($layout) {
|
||||||
$page = new View(__DIR__.'/../../views/console/users/index.phtml');
|
$page = new View(__DIR__.'/../../views/console/users/index.phtml');
|
||||||
|
|
||||||
$page->setParam('providers', $providers);
|
$page->setParam('providers', Config::getParam('providers'));
|
||||||
|
|
||||||
$layout
|
$layout
|
||||||
->setParam('title', APP_NAME.' - Users')
|
->setParam('title', APP_NAME.' - Users')
|
||||||
|
@ -242,7 +236,7 @@ $utopia->get('/console/users/view')
|
||||||
->desc('Platform console project user')
|
->desc('Platform console project user')
|
||||||
->label('permission', 'public')
|
->label('permission', 'public')
|
||||||
->label('scope', 'console')
|
->label('scope', 'console')
|
||||||
->action(function () use ($layout, $providers) {
|
->action(function () use ($layout) {
|
||||||
$page = new View(__DIR__.'/../../views/console/users/view.phtml');
|
$page = new View(__DIR__.'/../../views/console/users/view.phtml');
|
||||||
|
|
||||||
$layout
|
$layout
|
||||||
|
|
|
@ -2,22 +2,23 @@
|
||||||
|
|
||||||
include_once __DIR__ . '/../shared/web.php';
|
include_once __DIR__ . '/../shared/web.php';
|
||||||
|
|
||||||
global $utopia, $response, $request, $layout, $version, $providers, $platforms;
|
global $utopia, $response, $request, $layout;
|
||||||
|
|
||||||
use Utopia\View;
|
use Utopia\View;
|
||||||
|
use Utopia\Config\Config;
|
||||||
|
|
||||||
$header = new View(__DIR__.'/../../views/home/comps/header.phtml');
|
$header = new View(__DIR__.'/../../views/home/comps/header.phtml');
|
||||||
$footer = new View(__DIR__.'/../../views/home/comps/footer.phtml');
|
$footer = new View(__DIR__.'/../../views/home/comps/footer.phtml');
|
||||||
|
|
||||||
$footer
|
$footer
|
||||||
->setParam('version', $version)
|
->setParam('version', Config::getParam('version'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$layout
|
$layout
|
||||||
->setParam('title', APP_NAME)
|
->setParam('title', APP_NAME)
|
||||||
->setParam('description', '')
|
->setParam('description', '')
|
||||||
->setParam('class', 'home')
|
->setParam('class', 'home')
|
||||||
->setParam('platforms', $platforms)
|
->setParam('platforms', Config::getParam('platforms'))
|
||||||
->setParam('header', [$header])
|
->setParam('header', [$header])
|
||||||
->setParam('footer', [$footer])
|
->setParam('footer', [$footer])
|
||||||
;
|
;
|
||||||
|
|
47
app/init.php
47
app/init.php
|
@ -14,6 +14,7 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) {
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
use Utopia\Request;
|
use Utopia\Request;
|
||||||
use Utopia\Response;
|
use Utopia\Response;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Locale\Locale;
|
use Utopia\Locale\Locale;
|
||||||
use Utopia\Registry\Registry;
|
use Utopia\Registry\Registry;
|
||||||
use Appwrite\Auth\Auth;
|
use Appwrite\Auth\Auth;
|
||||||
|
@ -52,30 +53,31 @@ $response = new Response();
|
||||||
/*
|
/*
|
||||||
* ENV vars
|
* ENV vars
|
||||||
*/
|
*/
|
||||||
$env = $request->getServer('_APP_ENV', App::ENV_TYPE_PRODUCTION);
|
Config::load('providers', __DIR__.'/../app/config/providers.php');
|
||||||
$domain = $request->getServer('HTTP_HOST', '');
|
Config::load('platforms', __DIR__.'/../app/config/platforms.php');
|
||||||
$domainVerification = false;
|
Config::load('locales', __DIR__.'/../app/config/locales.php');
|
||||||
$version = $request->getServer('_APP_VERSION', 'UNKNOWN');
|
Config::load('collections', __DIR__.'/../app/config/collections.php');
|
||||||
$providers = include __DIR__.'/../app/config/providers.php'; // OAuth2 providers list
|
|
||||||
$platforms = include __DIR__.'/../app/config/platforms.php';
|
|
||||||
$locales = include __DIR__.'/../app/config/locales.php'; // Locales list
|
|
||||||
$collections = include __DIR__.'/../app/config/collections.php'; // Collections list
|
|
||||||
$redisHost = $request->getServer('_APP_REDIS_HOST', '');
|
|
||||||
$redisPort = $request->getServer('_APP_REDIS_PORT', '');
|
|
||||||
$utopia = new App('Asia/Tel_Aviv', $env);
|
|
||||||
$protocol = $request->getServer('HTTP_X_FORWARDED_PROTO', $request->getServer('REQUEST_SCHEME', 'https'));
|
|
||||||
$port = (string) parse_url($protocol.'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_PORT);
|
|
||||||
|
|
||||||
Resque::setBackend($redisHost.':'.$redisPort);
|
Config::setParam('env', $request->getServer('_APP_ENV', App::ENV_TYPE_PRODUCTION));
|
||||||
|
Config::setParam('domain', $request->getServer('HTTP_HOST', ''));
|
||||||
|
Config::setParam('domainVerification', false);
|
||||||
|
Config::setParam('version', $request->getServer('_APP_VERSION', 'UNKNOWN'));
|
||||||
|
Config::setParam('protocol', $request->getServer('HTTP_X_FORWARDED_PROTO', $request->getServer('REQUEST_SCHEME', 'https')));
|
||||||
|
Config::setParam('port', (string) parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_PORT));
|
||||||
|
|
||||||
|
$utopia = new App('Asia/Tel_Aviv', Config::getParam('env'));
|
||||||
|
|
||||||
|
Resque::setBackend($request->getServer('_APP_REDIS_HOST', '')
|
||||||
|
.':'.$request->getServer('_APP_REDIS_PORT', ''));
|
||||||
|
|
||||||
define('COOKIE_DOMAIN',
|
define('COOKIE_DOMAIN',
|
||||||
(
|
(
|
||||||
$request->getServer('HTTP_HOST', null) === 'localhost' ||
|
$request->getServer('HTTP_HOST', null) === 'localhost' ||
|
||||||
$request->getServer('HTTP_HOST', null) === 'localhost:'.$port ||
|
$request->getServer('HTTP_HOST', null) === 'localhost:'.Config::getParam('port') ||
|
||||||
(filter_var($request->getServer('HTTP_HOST', null), FILTER_VALIDATE_IP) !== false)
|
(filter_var($request->getServer('HTTP_HOST', null), FILTER_VALIDATE_IP) !== false)
|
||||||
)
|
)
|
||||||
? null
|
? null
|
||||||
: '.'.parse_url($protocol.'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_HOST));
|
: '.'.parse_url(Config::getParam('protocol').'://'.$request->getServer('HTTP_HOST', ''), PHP_URL_HOST));
|
||||||
define('COOKIE_SAMESITE', Response::COOKIE_SAMESITE_NONE);
|
define('COOKIE_SAMESITE', Response::COOKIE_SAMESITE_NONE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -119,10 +121,11 @@ $register->set('statsd', function () use ($request) { // Register DB connection
|
||||||
|
|
||||||
return $statsd;
|
return $statsd;
|
||||||
});
|
});
|
||||||
$register->set('cache', function () use ($redisHost, $redisPort) { // Register cache connection
|
$register->set('cache', function () use ($request) { // Register cache connection
|
||||||
$redis = new Redis();
|
$redis = new Redis();
|
||||||
|
|
||||||
$redis->connect($redisHost, $redisPort);
|
$redis->connect($request->getServer('_APP_REDIS_HOST', ''),
|
||||||
|
$request->getServer('_APP_REDIS_PORT', ''));
|
||||||
|
|
||||||
return $redis;
|
return $redis;
|
||||||
});
|
});
|
||||||
|
@ -209,7 +212,7 @@ Locale::setLanguage('zh-tw', include __DIR__.'/config/locales/zh-tw.php');
|
||||||
|
|
||||||
Locale::setDefault('en');
|
Locale::setDefault('en');
|
||||||
|
|
||||||
if (in_array($locale, $locales)) {
|
if (in_array($locale, Config::getParam('locales'))) {
|
||||||
Locale::setDefault($locale);
|
Locale::setDefault($locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +220,7 @@ stream_context_set_default([ // Set global user agent and http settings
|
||||||
'http' => [
|
'http' => [
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'user_agent' => sprintf(APP_USERAGENT,
|
'user_agent' => sprintf(APP_USERAGENT,
|
||||||
$version,
|
Config::getParam('version'),
|
||||||
$request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)),
|
$request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)),
|
||||||
'timeout' => 2,
|
'timeout' => 2,
|
||||||
],
|
],
|
||||||
|
@ -229,8 +232,8 @@ stream_context_set_default([ // Set global user agent and http settings
|
||||||
$consoleDB = new Database();
|
$consoleDB = new Database();
|
||||||
$consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
|
$consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
|
||||||
$consoleDB->setNamespace('app_console'); // Should be replaced with param if we want to have parent projects
|
$consoleDB->setNamespace('app_console'); // Should be replaced with param if we want to have parent projects
|
||||||
$consoleDB->setMocks($collections);
|
|
||||||
|
|
||||||
|
$consoleDB->setMocks(Config::getParam('collections', []));
|
||||||
Authorization::disable();
|
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', null)));
|
||||||
|
@ -268,7 +271,7 @@ Auth::$secret = $session['secret'];
|
||||||
$projectDB = new Database();
|
$projectDB = new Database();
|
||||||
$projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
|
$projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
|
||||||
$projectDB->setNamespace('app_'.$project->getId());
|
$projectDB->setNamespace('app_'.$project->getId());
|
||||||
$projectDB->setMocks($collections);
|
$projectDB->setMocks(Config::getParam('collections', []));
|
||||||
|
|
||||||
$user = $projectDB->getDocument(Auth::$unique);
|
$user = $projectDB->getDocument(Auth::$unique);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
require_once __DIR__.'/../../vendor/autoload.php';
|
require_once __DIR__.'/../../vendor/autoload.php';
|
||||||
require_once __DIR__.'/../../app/init.php';
|
require_once __DIR__.'/../../app/init.php';
|
||||||
|
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\CLI\CLI;
|
use Utopia\CLI\CLI;
|
||||||
use Utopia\CLI\Console;
|
use Utopia\CLI\Console;
|
||||||
use Appwrite\Spec\Swagger2;
|
use Appwrite\Spec\Swagger2;
|
||||||
|
@ -39,7 +40,7 @@ $cli
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
$platforms = include __DIR__ . '/../config/platforms.php';
|
$platforms = Config::getParam('platforms');
|
||||||
$message = Console::confirm('Please enter your commit message:');
|
$message = Console::confirm('Please enter your commit message:');
|
||||||
$production = (Console::confirm('Type "Appwrite" to deploy for production') == 'Appwrite');
|
$production = (Console::confirm('Type "Appwrite" to deploy for production') == 'Appwrite');
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
|
|
||||||
require_once __DIR__.'/../init.php';
|
require_once __DIR__.'/../init.php';
|
||||||
|
|
||||||
global $register, $projectDB, $console, $providers, $request;
|
global $register, $projectDB, $console, $request;
|
||||||
|
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\CLI\CLI;
|
use Utopia\CLI\CLI;
|
||||||
use Utopia\CLI\Console;
|
use Utopia\CLI\Console;
|
||||||
use Appwrite\Database\Database;
|
use Appwrite\Database\Database;
|
||||||
|
@ -93,7 +94,7 @@ $callbacks = [
|
||||||
];
|
];
|
||||||
|
|
||||||
function fixDocument(Document $document) {
|
function fixDocument(Document $document) {
|
||||||
global $providers;
|
$providers = Config::getParam('providers');
|
||||||
|
|
||||||
if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_PROJECTS){
|
if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_PROJECTS){
|
||||||
foreach($providers as $key => $provider) {
|
foreach($providers as $key => $provider) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Utopia\App;
|
use Utopia\App;
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Utopia\Domains\Domain;
|
use Utopia\Domains\Domain;
|
||||||
use Appwrite\Database\Database;
|
use Appwrite\Database\Database;
|
||||||
use Appwrite\Database\Validator\Authorization;
|
use Appwrite\Database\Validator\Authorization;
|
||||||
|
@ -22,7 +23,7 @@ class CertificatesV1
|
||||||
|
|
||||||
public function perform()
|
public function perform()
|
||||||
{
|
{
|
||||||
global $request, $consoleDB, $env;
|
global $request, $consoleDB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. Get new domain document - DONE
|
* 1. Get new domain document - DONE
|
||||||
|
@ -103,7 +104,7 @@ class CertificatesV1
|
||||||
throw new Exception('Renew isn\'t required');
|
throw new Exception('Renew isn\'t required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$staging = ($env === App::ENV_TYPE_PRODUCTION) ? '' : ' --dry-run';
|
$staging = (Config::getParam('env') === App::ENV_TYPE_PRODUCTION) ? '' : ' --dry-run';
|
||||||
|
|
||||||
$response = shell_exec("certbot certonly --webroot --noninteractive --agree-tos{$staging} --email security@appwrite.io \
|
$response = shell_exec("certbot certonly --webroot --noninteractive --agree-tos{$staging} --email security@appwrite.io \
|
||||||
-w ".APP_STORAGE_CERTIFICATES." \
|
-w ".APP_STORAGE_CERTIFICATES." \
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
require_once __DIR__.'/../init.php';
|
require_once __DIR__.'/../init.php';
|
||||||
|
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Appwrite\Database\Database;
|
use Appwrite\Database\Database;
|
||||||
use Appwrite\Database\Validator\Authorization;
|
use Appwrite\Database\Validator\Authorization;
|
||||||
use Cron\CronExpression;
|
use Cron\CronExpression;
|
||||||
|
@ -23,7 +24,7 @@ class TasksV1
|
||||||
|
|
||||||
public function perform()
|
public function perform()
|
||||||
{
|
{
|
||||||
global $consoleDB, $version, $request;
|
global $consoleDB, $request;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1. Get Original Task
|
* 1. Get Original Task
|
||||||
|
@ -94,7 +95,7 @@ class TasksV1
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, sprintf(APP_USERAGENT,
|
curl_setopt($ch, CURLOPT_USERAGENT, sprintf(APP_USERAGENT,
|
||||||
$version,
|
Config::getParam('version'),
|
||||||
$request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)
|
$request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)
|
||||||
));
|
));
|
||||||
curl_setopt(
|
curl_setopt(
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Utopia\Config\Config;
|
||||||
|
|
||||||
require_once __DIR__.'/../init.php';
|
require_once __DIR__.'/../init.php';
|
||||||
|
|
||||||
cli_set_process_title('Usage V1 Worker');
|
cli_set_process_title('Usage V1 Worker');
|
||||||
|
@ -19,7 +21,7 @@ class UsageV1
|
||||||
|
|
||||||
public function perform()
|
public function perform()
|
||||||
{
|
{
|
||||||
global $register, $version;
|
global $register;
|
||||||
|
|
||||||
$projectId = $this->args['projectId'];
|
$projectId = $this->args['projectId'];
|
||||||
$method = $this->args['method'];
|
$method = $this->args['method'];
|
||||||
|
@ -29,7 +31,7 @@ class UsageV1
|
||||||
|
|
||||||
$statsd = $register->get('statsd', true);
|
$statsd = $register->get('statsd', true);
|
||||||
|
|
||||||
$tags = ",project={$projectId},version=".$version.'';
|
$tags = ",project={$projectId},version=".Config::getParam('version').'';
|
||||||
|
|
||||||
// the global namespace is prepended to every key (optional)
|
// the global namespace is prepended to every key (optional)
|
||||||
$statsd->setNamespace('appwrite.usage');
|
$statsd->setNamespace('appwrite.usage');
|
||||||
|
|
|
@ -6,6 +6,7 @@ cli_set_process_title('Webhooks V1 Worker');
|
||||||
|
|
||||||
echo APP_NAME.' webhooks worker v1 has started';
|
echo APP_NAME.' webhooks worker v1 has started';
|
||||||
|
|
||||||
|
use Utopia\Config\Config;
|
||||||
use Appwrite\Database\Database;
|
use Appwrite\Database\Database;
|
||||||
use Appwrite\Database\Validator\Authorization;
|
use Appwrite\Database\Validator\Authorization;
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ class WebhooksV1
|
||||||
|
|
||||||
public function perform()
|
public function perform()
|
||||||
{
|
{
|
||||||
global $consoleDB, $version, $request;
|
global $consoleDB, $request;
|
||||||
|
|
||||||
$errors = [];
|
$errors = [];
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ class WebhooksV1
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, sprintf(APP_USERAGENT,
|
curl_setopt($ch, CURLOPT_USERAGENT, sprintf(APP_USERAGENT,
|
||||||
$version,
|
Config::getParam('version'),
|
||||||
$request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)
|
$request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)
|
||||||
));
|
));
|
||||||
curl_setopt(
|
curl_setopt(
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
"utopia-php/audit": "0.2.*",
|
"utopia-php/audit": "0.2.*",
|
||||||
"utopia-php/cache": "0.2.*",
|
"utopia-php/cache": "0.2.*",
|
||||||
"utopia-php/cli": "0.4.*",
|
"utopia-php/cli": "0.4.*",
|
||||||
|
"utopia-php/config": "0.2.*",
|
||||||
"utopia-php/locale": "0.2.*",
|
"utopia-php/locale": "0.2.*",
|
||||||
"utopia-php/registry": "0.2.*",
|
"utopia-php/registry": "0.2.*",
|
||||||
"utopia-php/domains": "0.2.*",
|
"utopia-php/domains": "0.2.*",
|
||||||
|
|
70
composer.lock
generated
70
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "54701e5067d9b94ae765f3f0e560b531",
|
"content-hash": "d19ba7d1c39970839f6f191664e9498d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "appwrite/php-clamav",
|
"name": "appwrite/php-clamav",
|
||||||
|
@ -1381,6 +1381,52 @@
|
||||||
],
|
],
|
||||||
"time": "2020-03-25T04:46:43+00:00"
|
"time": "2020-03-25T04:46:43+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "utopia-php/config",
|
||||||
|
"version": "0.2.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/utopia-php/config.git",
|
||||||
|
"reference": "f1f41d3863eb00bd2837b45c2e17e8b5da1cf46d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/utopia-php/config/zipball/f1f41d3863eb00bd2837b45c2e17e8b5da1cf46d",
|
||||||
|
"reference": "f1f41d3863eb00bd2837b45c2e17e8b5da1cf46d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^7.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Utopia\\Config\\": "src/Config"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Eldad Fux",
|
||||||
|
"email": "eldad@appwrite.io"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A simple Config library to managing application config variables",
|
||||||
|
"keywords": [
|
||||||
|
"config",
|
||||||
|
"framework",
|
||||||
|
"php",
|
||||||
|
"upf",
|
||||||
|
"utopia"
|
||||||
|
],
|
||||||
|
"time": "2020-03-28T10:24:18+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "utopia-php/domains",
|
"name": "utopia-php/domains",
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
|
@ -1576,7 +1622,7 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/appwrite/sdk-generator",
|
"url": "https://github.com/appwrite/sdk-generator",
|
||||||
"reference": "7a43413e650705843672ebe930fe6ecd77693393"
|
"reference": "97cb12c9c187a42a545060c324b0960c99582893"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
|
@ -1606,7 +1652,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
||||||
"time": "2020-03-01T12:19:20+00:00"
|
"time": "2020-03-27T15:12:28+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/instantiator",
|
"name": "doctrine/instantiator",
|
||||||
|
@ -2395,16 +2441,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit",
|
"name": "phpunit/phpunit",
|
||||||
"version": "7.5.20",
|
"version": "7.5.x-dev",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||||
"reference": "9467db479d1b0487c99733bb1e7944d32deded2c"
|
"reference": "6ef9ac810e494e7793013f8f5004d5d268852412"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6ef9ac810e494e7793013f8f5004d5d268852412",
|
||||||
"reference": "9467db479d1b0487c99733bb1e7944d32deded2c",
|
"reference": "6ef9ac810e494e7793013f8f5004d5d268852412",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2475,7 +2521,7 @@
|
||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2020-01-08T08:45:45+00:00"
|
"time": "2019-11-27T08:45:03+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/code-unit-reverse-lookup",
|
"name": "sebastian/code-unit-reverse-lookup",
|
||||||
|
@ -3206,12 +3252,12 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
"reference": "27af7d9cd1b77fcb13b4ed452c291d9defad088b"
|
"reference": "6df2e2c3181e6d0b961fc341fbe8269fefc933c6"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/27af7d9cd1b77fcb13b4ed452c291d9defad088b",
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/6df2e2c3181e6d0b961fc341fbe8269fefc933c6",
|
||||||
"reference": "27af7d9cd1b77fcb13b4ed452c291d9defad088b",
|
"reference": "6df2e2c3181e6d0b961fc341fbe8269fefc933c6",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -3263,7 +3309,7 @@
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"templating"
|
"templating"
|
||||||
],
|
],
|
||||||
"time": "2020-03-24T12:35:30+00:00"
|
"time": "2020-03-27T16:41:01+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "webmozart/assert",
|
"name": "webmozart/assert",
|
||||||
|
|
Loading…
Reference in a new issue