From 27850c660f8e5473ef4349168adee430db75c420 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 1 Mar 2020 19:05:51 +0200 Subject: [PATCH] Updated env vars --- app/controllers/api/avatars.php | 7 +++++-- app/init.php | 10 ++++++---- app/workers/tasks.php | 7 +++++-- app/workers/webhooks.php | 7 +++++-- src/Auth/OAuth2.php | 2 +- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index 369cba85f..675a87173 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -206,7 +206,7 @@ $utopia->get('/v1/avatars/favicon') ->label('sdk.method', 'getFavicon') ->label('sdk.description', '/docs/references/avatars/get-favicon.md') ->action( - function ($url) use ($response, $version) { + function ($url) use ($response, $request, $version) { $width = 56; $height = 56; $quality = 80; @@ -237,7 +237,10 @@ $utopia->get('/v1/avatars/favicon') CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 3, CURLOPT_URL => $url, - CURLOPT_USERAGENT => sprintf(APP_USERAGENT, $version), + CURLOPT_USERAGENT => sprintf(APP_USERAGENT, + $version, + $request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) + ), ]); $html = curl_exec($curl); diff --git a/app/init.php b/app/init.php index a0139f524..6660640ad 100644 --- a/app/init.php +++ b/app/init.php @@ -20,9 +20,9 @@ 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_EMAIL_TEAM = 'team@localhost'; // Default email address +const APP_EMAIL_SECURITY = 'security@localhost'; // Default security email address +const APP_USERAGENT = APP_NAME.'-Server v%s. Please report abuse at %s'; const APP_MODE_ADMIN = 'admin'; const APP_PAGING_LIMIT = 15; const APP_CACHE_BUSTER = 48; @@ -209,7 +209,9 @@ if (in_array($locale, $locales)) { stream_context_set_default([ // Set global user agent and http settings 'http' => [ 'method' => 'GET', - 'user_agent' => sprintf(APP_USERAGENT, $version), + 'user_agent' => sprintf(APP_USERAGENT, + $version, + $request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY)), 'timeout' => 2, ], ]); diff --git a/app/workers/tasks.php b/app/workers/tasks.php index eaf722ec7..54a0f43ea 100644 --- a/app/workers/tasks.php +++ b/app/workers/tasks.php @@ -23,7 +23,7 @@ class TasksV1 public function perform() { - global $consoleDB, $version; + global $consoleDB, $version, $request; /* * 1. Get Original Task @@ -93,7 +93,10 @@ class TasksV1 curl_setopt($ch, CURLOPT_POSTFIELDS, ''); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_USERAGENT, sprintf(APP_USERAGENT, $version)); + curl_setopt($ch, CURLOPT_USERAGENT, sprintf(APP_USERAGENT, + $version, + $request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) + )); curl_setopt( $ch, CURLOPT_HTTPHEADER, diff --git a/app/workers/webhooks.php b/app/workers/webhooks.php index dd03f3b26..62633022e 100644 --- a/app/workers/webhooks.php +++ b/app/workers/webhooks.php @@ -19,7 +19,7 @@ class WebhooksV1 public function perform() { - global $consoleDB, $version; + global $consoleDB, $version, $request; $errors = []; @@ -58,7 +58,10 @@ class WebhooksV1 curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_USERAGENT, sprintf(APP_USERAGENT, $version)); + curl_setopt($ch, CURLOPT_USERAGENT, sprintf(APP_USERAGENT, + $version, + $request->getServer('_APP_SYSTEM_SECURITY_EMAIL_ADDRESS', APP_EMAIL_SECURITY) + )); curl_setopt( $ch, CURLOPT_HTTPHEADER, diff --git a/src/Auth/OAuth2.php b/src/Auth/OAuth2.php index 37a542b56..7bae79ac6 100644 --- a/src/Auth/OAuth2.php +++ b/src/Auth/OAuth2.php @@ -138,7 +138,7 @@ abstract class OAuth2 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_USERAGENT, APP_USERAGENT); + curl_setopt($ch, CURLOPT_USERAGENT, ''); if (!empty($payload)) { curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);