Disallow HTTP communication if required
This commit is contained in:
parent
d69aba54c0
commit
45e9040fa5
|
@ -78,6 +78,11 @@ return [
|
||||||
'description' => 'An internal server error occurred.',
|
'description' => 'An internal server error occurred.',
|
||||||
'code' => 500,
|
'code' => 500,
|
||||||
],
|
],
|
||||||
|
Exception::GENERAL_FORCED_HTTPS_IGNORED => [
|
||||||
|
'name' => Exception::GENERAL_FORCED_HTTPS_IGNORED,
|
||||||
|
'description' => 'Appwrite instance forces secure communication. Switch to HTTPS protocol in your endpoint.',
|
||||||
|
'code' => 500,
|
||||||
|
],
|
||||||
|
|
||||||
/** User Errors */
|
/** User Errors */
|
||||||
Exception::USER_COUNT_EXCEEDED => [
|
Exception::USER_COUNT_EXCEEDED => [
|
||||||
|
|
|
@ -173,6 +173,10 @@ App::init(function ($utopia, $request, $response, $console, $project, $dbForCons
|
||||||
*/
|
*/
|
||||||
if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
|
if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
|
||||||
if ($request->getProtocol() !== 'https') {
|
if ($request->getProtocol() !== 'https') {
|
||||||
|
if($request->getMethod() !== Request::METHOD_GET) {
|
||||||
|
throw new Exception('HTTPS communication required.', 500, Exception::GENERAL_FORCED_HTTPS_IGNORED);
|
||||||
|
}
|
||||||
|
|
||||||
return $response->redirect('https://'.$request->getHostname().$request->getURI());
|
return $response->redirect('https://'.$request->getHostname().$request->getURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
28
composer.lock
generated
28
composer.lock
generated
|
@ -478,16 +478,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/guzzle",
|
"name": "guzzlehttp/guzzle",
|
||||||
"version": "7.4.1",
|
"version": "7.4.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/guzzle.git",
|
"url": "https://github.com/guzzle/guzzle.git",
|
||||||
"reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79"
|
"reference": "ac1ec1cd9b5624694c3a40be801d94137afb12b4"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/ee0a041b1760e6a53d2a39c8c34115adc2af2c79",
|
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/ac1ec1cd9b5624694c3a40be801d94137afb12b4",
|
||||||
"reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79",
|
"reference": "ac1ec1cd9b5624694c3a40be801d94137afb12b4",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -582,7 +582,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/guzzle/guzzle/issues",
|
"issues": "https://github.com/guzzle/guzzle/issues",
|
||||||
"source": "https://github.com/guzzle/guzzle/tree/7.4.1"
|
"source": "https://github.com/guzzle/guzzle/tree/7.4.2"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -598,7 +598,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-12-06T18:43:05+00:00"
|
"time": "2022-03-20T14:16:28+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/promises",
|
"name": "guzzlehttp/promises",
|
||||||
|
@ -686,16 +686,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/psr7",
|
"name": "guzzlehttp/psr7",
|
||||||
"version": "2.1.0",
|
"version": "2.2.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/psr7.git",
|
"url": "https://github.com/guzzle/psr7.git",
|
||||||
"reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72"
|
"reference": "c94a94f120803a18554c1805ef2e539f8285f9a2"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72",
|
"url": "https://api.github.com/repos/guzzle/psr7/zipball/c94a94f120803a18554c1805ef2e539f8285f9a2",
|
||||||
"reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72",
|
"reference": "c94a94f120803a18554c1805ef2e539f8285f9a2",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -719,7 +719,7 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.1-dev"
|
"dev-master": "2.2-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -781,7 +781,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/guzzle/psr7/issues",
|
"issues": "https://github.com/guzzle/psr7/issues",
|
||||||
"source": "https://github.com/guzzle/psr7/tree/2.1.0"
|
"source": "https://github.com/guzzle/psr7/tree/2.2.1"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -797,7 +797,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-10-06T17:43:30+00:00"
|
"time": "2022-03-20T21:55:58+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "influxdb/influxdb-php",
|
"name": "influxdb/influxdb-php",
|
||||||
|
@ -6580,5 +6580,5 @@
|
||||||
"platform-overrides": {
|
"platform-overrides": {
|
||||||
"php": "8.0"
|
"php": "8.0"
|
||||||
},
|
},
|
||||||
"plugin-api-version": "2.1.0"
|
"plugin-api-version": "2.2.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ class Exception extends \Exception
|
||||||
const GENERAL_ROUTE_NOT_FOUND = 'general_route_not_found';
|
const GENERAL_ROUTE_NOT_FOUND = 'general_route_not_found';
|
||||||
const GENERAL_CURSOR_NOT_FOUND = 'general_cursor_not_found';
|
const GENERAL_CURSOR_NOT_FOUND = 'general_cursor_not_found';
|
||||||
const GENERAL_SERVER_ERROR = 'general_server_error';
|
const GENERAL_SERVER_ERROR = 'general_server_error';
|
||||||
|
const GENERAL_FORCED_HTTPS_IGNORED = 'general_forced_https_ignored';
|
||||||
|
|
||||||
/** Users */
|
/** Users */
|
||||||
const USER_COUNT_EXCEEDED = 'user_count_exceeded';
|
const USER_COUNT_EXCEEDED = 'user_count_exceeded';
|
||||||
|
|
Loading…
Reference in a new issue