From 1c9b29986b094229678b2d309bb4795c41834101 Mon Sep 17 00:00:00 2001 From: devuri Date: Fri, 9 Feb 2024 19:25:21 -0500 Subject: [PATCH] chore: build --- .../code/classes/Urisoft-App-Core-Plugin.html | 10 +- .../Urisoft-App-Http-AppFramework.html | 56 +---- docs/code/classes/Urisoft-App-Http-DB.html | 61 ++++- docs/code/classes/Urisoft-App-Setup.html | 180 +++---------- docs/code/files/src-app-setup.html | 85 ------- docs/code/files/src-inc-helpers.html | 236 ++++++++++++++++-- docs/code/index.html | 174 ++++++++++--- docs/code/js/searchIndex.js | 60 ++--- docs/code/namespaces/default.html | 174 ++++++++++--- docs/code/packages/Application.html | 174 ++++++++++--- docs/code/reports/markers.html | 28 +-- docs/multi-tenant/index.md | 26 +- tests/Unit/ScleanSensitiveEnvTest.php | 39 +++ tests/stubs.php | 1 + 14 files changed, 815 insertions(+), 489 deletions(-) create mode 100644 tests/Unit/ScleanSensitiveEnvTest.php diff --git a/docs/code/classes/Urisoft-App-Core-Plugin.html b/docs/code/classes/Urisoft-App-Core-Plugin.html index 21fc901..4310097 100644 --- a/docs/code/classes/Urisoft-App-Core-Plugin.html +++ b/docs/code/classes/Urisoft-App-Core-Plugin.html @@ -553,7 +553,7 @@

Plugin.php : - 202 + 198 @@ -675,7 +675,7 @@

@@ -741,7 +741,7 @@

@@ -774,7 +774,7 @@

@@ -821,7 +821,7 @@

diff --git a/docs/code/classes/Urisoft-App-Http-AppFramework.html b/docs/code/classes/Urisoft-App-Http-AppFramework.html index 18f165d..0383385 100644 --- a/docs/code/classes/Urisoft-App-Http-AppFramework.html +++ b/docs/code/classes/Urisoft-App-Http-AppFramework.html @@ -181,13 +181,6 @@

Set the config options.
-
- _is_multitenant() - -  : mixed -
-
- @@ -330,7 +323,7 @@

public - __construct(string $app_path[, string $options = 'app' ][, array<string|int, mixed>|null $tenant_ids = null ]) : mixed + __construct(string $app_path[, string $options = 'app' ]) : mixed

Parameters
@@ -352,14 +345,6 @@
Parameters

The configuration options filename, e.g., app.php.

- -
- $tenant_ids - : array<string|int, mixed>|null - = null
-
-
-
@@ -400,7 +385,7 @@

@@ -435,7 +420,7 @@

@@ -468,7 +453,7 @@

@@ -508,39 +493,6 @@

Return values
— - -
-

- _is_multitenant() - -

- - - - - private - static _is_multitenant() : mixed - -
- - - - -
Return values
- mixed - — - -
diff --git a/docs/code/classes/Urisoft-App-Http-DB.html b/docs/code/classes/Urisoft-App-Http-DB.html index df2cf23..f6c6368 100644 --- a/docs/code/classes/Urisoft-App-Http-DB.html +++ b/docs/code/classes/Urisoft-App-Http-DB.html @@ -158,6 +158,13 @@

 : mixed +
+ +
+ $prefix + +  : mixed +
@@ -356,6 +363,40 @@

+ +
+

+ $prefix + + + +

+ + + + + private + mixed + $prefix + + +
+ +
+ + +
public - __construct(string $table_name_no_prefix, string $host, string $dbName, string $username, string $password) : mixed + __construct(string $table_name_no_prefix, string $host, string $dbName, string $username, string $password, string $prefix) : mixed
@@ -497,6 +538,14 @@
Parameters
+
+
+ $prefix + : string +
+
+
+
@@ -521,7 +570,7 @@

@@ -554,7 +603,7 @@

@@ -598,7 +647,7 @@

@@ -650,7 +699,7 @@

diff --git a/docs/code/classes/Urisoft-App-Setup.html b/docs/code/classes/Urisoft-App-Setup.html index 5e42a06..4bef24f 100644 --- a/docs/code/classes/Urisoft-App-Setup.html +++ b/docs/code/classes/Urisoft-App-Setup.html @@ -117,7 +117,7 @@

@@ -150,13 +150,6 @@

- $app_http_host - -  : string -
-
Set the http host.
- -
$dotenv  : mixed @@ -268,13 +261,6 @@

Debug Settings.
-
- define_multi_tenant() - -  : void -
-
-
env_debug() @@ -422,13 +408,6 @@

Retrieves the default file names for environment configuration.
-
- http() - -  : AppHostManager -
-
-
is_multitenant_app() @@ -482,39 +461,6 @@

-property -protected " -> -

- $app_http_host - - - -

- - -

Set the http host.

- - - protected - string - $app_http_host - - - - - - -

-

$dotenv @@ -525,7 +471,7 @@

@@ -559,7 +505,7 @@

@@ -592,7 +538,7 @@

@@ -625,7 +571,7 @@

@@ -658,7 +604,7 @@

@@ -691,7 +637,7 @@

@@ -724,7 +670,7 @@

@@ -757,7 +703,7 @@

@@ -791,7 +737,7 @@

@@ -825,7 +771,7 @@

@@ -862,7 +808,7 @@

@@ -870,7 +816,7 @@

public - __construct(string $path[, array<string|int, mixed> $supported_names_or_tenants = [] ][, bool $short_circuit = true ]) : mixed + __construct(string $path[, array<string|int, mixed> $supported_names = [] ][, bool $short_circuit = true ]) : mixed

Parameters
@@ -885,7 +831,7 @@
Parameters
- $supported_names_or_tenants + $supported_names : array<string|int, mixed> = []
@@ -991,7 +937,7 @@

@@ -1078,7 +1024,7 @@

@@ -1107,39 +1053,6 @@

Return values
— -
-
-

- define_multi_tenant() - -

- - - - - public - define_multi_tenant() : void - -
- - - - -
Return values
- void - — - -
@@ -1400,7 +1313,7 @@

@@ -1433,7 +1346,7 @@

@@ -1481,7 +1394,7 @@

@@ -1590,7 +1503,7 @@

@@ -1672,7 +1585,7 @@

@@ -1705,7 +1618,7 @@

@@ -1831,7 +1744,7 @@

@@ -1864,7 +1777,7 @@

@@ -1897,7 +1810,7 @@

@@ -1950,39 +1863,6 @@

Return values
-
-
@@ -2030,7 +1910,7 @@

@@ -2096,7 +1976,7 @@

@@ -2141,7 +2021,7 @@

diff --git a/docs/code/files/src-app-setup.html b/docs/code/files/src-app-setup.html index 004e002..99e9d62 100644 --- a/docs/code/files/src-app-setup.html +++ b/docs/code/files/src-app-setup.html @@ -116,95 +116,10 @@

-

- Table of Contents - -

- -
-
- APP_HTTP_HOST - -  = $this->app_http_host -
-
- -
- IS_MULTITENANT - -  = false -
-
- -
-
-

- Constants - -

-
-

- APP_HTTP_HOST - -

- - - - - - public - mixed - APP_HTTP_HOST - = $this->app_http_host - - - -
- -
- - - -
-
-

- IS_MULTITENANT - -

- - - - - - public - mixed - IS_MULTITENANT - = false - - - -
- -
- - - -
-
diff --git a/docs/code/files/src-inc-helpers.html b/docs/code/files/src-inc-helpers.html index 79550eb..7ae8173 100644 --- a/docs/code/files/src-inc-helpers.html +++ b/docs/code/files/src-inc-helpers.html @@ -110,6 +110,27 @@

+
+ APP_HTTP_HOST + +  = $hostd[0]->domain +
+
+ +
+ APP_TENANT_ID + +  = $hostd[0]->uuid +
+
+ +
+ IS_MULTITENANT + +  = true +
+
+
asset() @@ -201,6 +222,13 @@

Basic Sanitize and prepare for a string input for safe usage in the application.
+
+ env_tenant_id() + +  : string|null +
+
+
wp_terminate() @@ -208,11 +236,111 @@

Custom function to terminate script execution, display a message, and set an HTTP status code.
+
+ sclean_sensitive_env() + +  : void +
+
Cleans up sensitive environment variables.
+
+
+

+ Constants + +

+
+

+ APP_HTTP_HOST + +

+ + + + + + public + mixed + APP_HTTP_HOST + = $hostd[0]->domain + + + +
+ +
+ + + +
+
+

+ APP_TENANT_ID + +

+ + + + + + public + mixed + APP_TENANT_ID + = $hostd[0]->uuid + + + +
+ +
+ + + +
+
+

+ IS_MULTITENANT + +

+ + + + + + public + mixed + IS_MULTITENANT + = true + + + +
+ +
+ + + +
+

@@ -227,7 +355,7 @@

@@ -277,7 +405,7 @@

@@ -315,7 +443,7 @@

@@ -385,7 +513,7 @@

@@ -427,7 +555,7 @@

@@ -467,7 +595,7 @@

- wpc_app(string $app_path[, string $options = 'app' ][, null|array<string|int, mixed> $tenant_ids = null ]) : BaseKernel + wpc_app(string $app_path[, string $options = 'app' ]) : BaseKernel

Optionally supports a multi-tenant configuration based on environment variables.

@@ -491,15 +619,6 @@

Parameters

The configuration filename, defaults to 'app'.

- -
- $tenant_ids - : null|array<string|int, mixed> - = null
-
-

Optional array of tenant IDs for multi-tenant support.

-
-
@@ -521,7 +640,7 @@

@@ -549,7 +668,7 @@

@@ -592,7 +711,7 @@

@@ -635,7 +754,7 @@

@@ -715,7 +834,7 @@

@@ -791,7 +910,7 @@

helpers.php : - 292 + 308 @@ -819,7 +938,7 @@

@@ -856,6 +975,34 @@

Return values
+ +
+

+ env_tenant_id() + +

+ + + + + + env_tenant_id() : string|null + +
+ + + + +
Return values
+ string|null + — + +

@@ -865,7 +1012,7 @@

@@ -905,6 +1052,49 @@

Return values
— +
+
+

+ sclean_sensitive_env() + +

+ + +

Cleans up sensitive environment variables.

+ + + + sclean_sensitive_env(array<string|int, mixed> $sensitives) : void + +

This function removes specified environment variables from the $_ENV superglobal +and the environment to help secure sensitive information.

+
+ +
Parameters
+
+
+ $sensitives + : array<string|int, mixed> +
+
+

An array of environment variable names to be cleaned up.

+
+ +
+
+ + + +
Return values
+ void + — + +
diff --git a/docs/code/index.html b/docs/code/index.html index 0af5a7c..6f89d69 100644 --- a/docs/code/index.html +++ b/docs/code/index.html @@ -120,14 +120,21 @@

APP_HTTP_HOST -  = $this->app_http_host +  = $hostd[0]->domain +
+
+ +
+ APP_TENANT_ID + +  = $hostd[0]->uuid
IS_MULTITENANT -  = false +  = true
@@ -222,6 +229,13 @@

Basic Sanitize and prepare for a string input for safe usage in the application.
+
+ env_tenant_id() + +  : string|null +
+
+
wp_terminate() @@ -229,6 +243,13 @@

Custom function to terminate script execution, display a message, and set an HTTP status code.
+
+ sclean_sensitive_env() + +  : void +
+
Cleans up sensitive environment variables.
+ @@ -244,9 +265,9 @@

@@ -255,7 +276,36 @@

public mixed APP_HTTP_HOST - = $this->app_http_host + = $hostd[0]->domain + + + +
+ +
+ + + + +
+

+ APP_TENANT_ID + +

+ + + + + + public + mixed + APP_TENANT_ID + = $hostd[0]->uuid @@ -273,9 +323,9 @@

@@ -284,7 +334,7 @@

public mixed IS_MULTITENANT - = false + = true @@ -310,7 +360,7 @@

@@ -360,7 +410,7 @@

@@ -398,7 +448,7 @@

@@ -468,7 +518,7 @@

@@ -510,7 +560,7 @@

@@ -550,7 +600,7 @@

- wpc_app(string $app_path[, string $options = 'app' ][, null|array<string|int, mixed> $tenant_ids = null ]) : BaseKernel + wpc_app(string $app_path[, string $options = 'app' ]) : BaseKernel

Optionally supports a multi-tenant configuration based on environment variables.

@@ -574,15 +624,6 @@

Parameters

The configuration filename, defaults to 'app'.

- -
- $tenant_ids - : null|array<string|int, mixed> - = null
-
-

Optional array of tenant IDs for multi-tenant support.

-
-
@@ -604,7 +645,7 @@

@@ -632,7 +673,7 @@

@@ -675,7 +716,7 @@

@@ -718,7 +759,7 @@

@@ -798,7 +839,7 @@

@@ -874,7 +915,7 @@

helpers.php : - 292 + 308 @@ -902,7 +943,7 @@

@@ -939,6 +980,34 @@

Return values
+
+
+

+ env_tenant_id() + +

+ + + + + + env_tenant_id() : string|null + +
+ + + + +
Return values
+ string|null + — + +

@@ -948,7 +1017,7 @@

@@ -988,6 +1057,49 @@

Return values
— +
+
+

+ sclean_sensitive_env() + +

+ + +

Cleans up sensitive environment variables.

+ + + + sclean_sensitive_env(array<string|int, mixed> $sensitives) : void + +

This function removes specified environment variables from the $_ENV superglobal +and the environment to help secure sensitive information.

+
+ +
Parameters
+
+
+ $sensitives + : array<string|int, mixed> +
+
+

An array of environment variable names to be cleaned up.

+
+ +
+
+ + + +
Return values
+ void + — + +
diff --git a/docs/code/js/searchIndex.js b/docs/code/js/searchIndex.js index 7a78c44..e43cdfd 100644 --- a/docs/code/js/searchIndex.js +++ b/docs/code/js/searchIndex.js @@ -535,16 +535,6 @@ Search.appendIndex( "name": "__construct", "summary": "Setup\u0020Kernel.", "url": "classes/Urisoft-App-Kernel.html#method___construct" - }, { - "fqsen": "\\APP_HTTP_HOST", - "name": "APP_HTTP_HOST", - "summary": "", - "url": "namespaces/default.html#constant_APP_HTTP_HOST" - }, { - "fqsen": "\\IS_MULTITENANT", - "name": "IS_MULTITENANT", - "summary": "", - "url": "namespaces/default.html#constant_IS_MULTITENANT" }, { "fqsen": "\\Urisoft\\App\\Setup", "name": "Setup", @@ -555,11 +545,6 @@ Search.appendIndex( "name": "__construct", "summary": "Constructor\u0020for\u0020initializing\u0020the\u0020application\u0020environment\u0020and\u0020configuration.", "url": "classes/Urisoft-App-Setup.html#method___construct" - }, { - "fqsen": "\\Urisoft\\App\\Setup\u003A\u003Adefine_multi_tenant\u0028\u0029", - "name": "define_multi_tenant", - "summary": "", - "url": "classes/Urisoft-App-Setup.html#method_define_multi_tenant" }, { "fqsen": "\\Urisoft\\App\\Setup\u003A\u003Ainit\u0028\u0029", "name": "init", @@ -630,11 +615,6 @@ Search.appendIndex( "name": "is_required", "summary": "", "url": "classes/Urisoft-App-Setup.html#method_is_required" - }, { - "fqsen": "\\Urisoft\\App\\Setup\u003A\u003Ahttp\u0028\u0029", - "name": "http", - "summary": "", - "url": "classes/Urisoft-App-Setup.html#method_http" }, { "fqsen": "\\Urisoft\\App\\Setup\u003A\u003Aget_env\u0028\u0029", "name": "get_env", @@ -695,11 +675,6 @@ Search.appendIndex( "name": "env_types", "summary": "Set\u0020supported\u0020env\u0020types.", "url": "classes/Urisoft-App-Setup.html#property_env_types" - }, { - "fqsen": "\\Urisoft\\App\\Setup\u003A\u003A\u0024app_http_host", - "name": "app_http_host", - "summary": "Set\u0020the\u0020http\u0020host.", - "url": "classes/Urisoft-App-Setup.html#property_app_http_host" }, { "fqsen": "\\Urisoft\\App\\Traits\\ConfigTrait", "name": "ConfigTrait", @@ -750,6 +725,21 @@ Search.appendIndex( "name": "const", "summary": "Env\u0020defaults.", "url": "classes/Urisoft-App-Traits-ConfigTrait.html#method_const" + }, { + "fqsen": "\\APP_HTTP_HOST", + "name": "APP_HTTP_HOST", + "summary": "", + "url": "namespaces/default.html#constant_APP_HTTP_HOST" + }, { + "fqsen": "\\APP_TENANT_ID", + "name": "APP_TENANT_ID", + "summary": "", + "url": "namespaces/default.html#constant_APP_TENANT_ID" + }, { + "fqsen": "\\IS_MULTITENANT", + "name": "IS_MULTITENANT", + "summary": "", + "url": "namespaces/default.html#constant_IS_MULTITENANT" }, { "fqsen": "\\asset\u0028\u0029", "name": "asset", @@ -815,11 +805,21 @@ Search.appendIndex( "name": "app_sanitizer", "summary": "Basic\u0020Sanitize\u0020and\u0020prepare\u0020for\u0020a\u0020string\u0020input\u0020for\u0020safe\u0020usage\u0020in\u0020the\u0020application.", "url": "namespaces/default.html#function_app_sanitizer" + }, { + "fqsen": "\\env_tenant_id\u0028\u0029", + "name": "env_tenant_id", + "summary": "", + "url": "namespaces/default.html#function_env_tenant_id" }, { "fqsen": "\\wp_terminate\u0028\u0029", "name": "wp_terminate", "summary": "Custom\u0020function\u0020to\u0020terminate\u0020script\u0020execution,\u0020display\u0020a\u0020message,\u0020and\u0020set\u0020an\u0020HTTP\u0020status\u0020code.", "url": "namespaces/default.html#function_wp_terminate" + }, { + "fqsen": "\\sclean_sensitive_env\u0028\u0029", + "name": "sclean_sensitive_env", + "summary": "Cleans\u0020up\u0020sensitive\u0020environment\u0020variables.", + "url": "namespaces/default.html#function_sclean_sensitive_env" }, { "fqsen": "\\Urisoft\\App\\Core\\AutoLogin", "name": "AutoLogin", @@ -1305,11 +1305,6 @@ Search.appendIndex( "name": "set_config", "summary": "Set\u0020the\u0020config\u0020options.", "url": "classes/Urisoft-App-Http-AppFramework.html#method_set_config" - }, { - "fqsen": "\\Urisoft\\App\\Http\\AppFramework\u003A\u003A_is_multitenant\u0028\u0029", - "name": "_is_multitenant", - "summary": "", - "url": "classes/Urisoft-App-Http-AppFramework.html#method__is_multitenant" }, { "fqsen": "\\Urisoft\\App\\Http\\AppFramework\u003A\u003A\u0024app_path", "name": "app_path", @@ -1470,6 +1465,11 @@ Search.appendIndex( "name": "table", "summary": "", "url": "classes/Urisoft-App-Http-DB.html#property_table" + }, { + "fqsen": "\\Urisoft\\App\\Http\\DB\u003A\u003A\u0024prefix", + "name": "prefix", + "summary": "", + "url": "classes/Urisoft-App-Http-DB.html#property_prefix" }, { "fqsen": "\\", "name": "\\", diff --git a/docs/code/namespaces/default.html b/docs/code/namespaces/default.html index 63495b6..722ead8 100644 --- a/docs/code/namespaces/default.html +++ b/docs/code/namespaces/default.html @@ -115,14 +115,21 @@

APP_HTTP_HOST -  = $this->app_http_host +  = $hostd[0]->domain +
+
+ +
+ APP_TENANT_ID + +  = $hostd[0]->uuid
IS_MULTITENANT -  = false +  = true
@@ -217,6 +224,13 @@

Basic Sanitize and prepare for a string input for safe usage in the application.
+
+ env_tenant_id() + +  : string|null +
+
+
wp_terminate() @@ -224,6 +238,13 @@

Custom function to terminate script execution, display a message, and set an HTTP status code.
+
+ sclean_sensitive_env() + +  : void +
+
Cleans up sensitive environment variables.
+ @@ -239,9 +260,9 @@

@@ -250,7 +271,36 @@

public mixed APP_HTTP_HOST - = $this->app_http_host + = $hostd[0]->domain + + + +
+ +
+ + + + +
+

+ APP_TENANT_ID + +

+ + + + + + public + mixed + APP_TENANT_ID + = $hostd[0]->uuid @@ -268,9 +318,9 @@

@@ -279,7 +329,7 @@

public mixed IS_MULTITENANT - = false + = true @@ -305,7 +355,7 @@

@@ -355,7 +405,7 @@

@@ -393,7 +443,7 @@

@@ -463,7 +513,7 @@

@@ -505,7 +555,7 @@

@@ -545,7 +595,7 @@

- wpc_app(string $app_path[, string $options = 'app' ][, null|array<string|int, mixed> $tenant_ids = null ]) : BaseKernel + wpc_app(string $app_path[, string $options = 'app' ]) : BaseKernel

Optionally supports a multi-tenant configuration based on environment variables.

@@ -569,15 +619,6 @@

Parameters

The configuration filename, defaults to 'app'.

- -
- $tenant_ids - : null|array<string|int, mixed> - = null
-
-

Optional array of tenant IDs for multi-tenant support.

-
-
@@ -599,7 +640,7 @@

@@ -627,7 +668,7 @@

@@ -670,7 +711,7 @@

@@ -713,7 +754,7 @@

@@ -793,7 +834,7 @@

@@ -869,7 +910,7 @@

helpers.php : - 292 + 308 @@ -897,7 +938,7 @@

@@ -934,6 +975,34 @@

Return values
+
+
+

+ env_tenant_id() + +

+ + + + + + env_tenant_id() : string|null + +
+ + + + +
Return values
+ string|null + — + +

@@ -943,7 +1012,7 @@

@@ -983,6 +1052,49 @@

Return values
— +
+
+

+ sclean_sensitive_env() + +

+ + +

Cleans up sensitive environment variables.

+ + + + sclean_sensitive_env(array<string|int, mixed> $sensitives) : void + +

This function removes specified environment variables from the $_ENV superglobal +and the environment to help secure sensitive information.

+
+ +
Parameters
+
+
+ $sensitives + : array<string|int, mixed> +
+
+

An array of environment variable names to be cleaned up.

+
+ +
+
+ + + +
Return values
+ void + — + +
diff --git a/docs/code/packages/Application.html b/docs/code/packages/Application.html index 7f7d88a..b28da13 100644 --- a/docs/code/packages/Application.html +++ b/docs/code/packages/Application.html @@ -184,14 +184,21 @@

APP_HTTP_HOST -  = $this->app_http_host +  = $hostd[0]->domain +
+
+ +
+ APP_TENANT_ID + +  = $hostd[0]->uuid
IS_MULTITENANT -  = false +  = true
@@ -286,6 +293,13 @@

Basic Sanitize and prepare for a string input for safe usage in the application.
+
+ env_tenant_id() + +  : string|null +
+
+
wp_terminate() @@ -293,6 +307,13 @@

Custom function to terminate script execution, display a message, and set an HTTP status code.
+
+ sclean_sensitive_env() + +  : void +
+
Cleans up sensitive environment variables.
+ @@ -308,9 +329,9 @@

@@ -319,7 +340,36 @@

public mixed APP_HTTP_HOST - = $this->app_http_host + = $hostd[0]->domain + + + +
+ +
+ + + + +
+

+ APP_TENANT_ID + +

+ + + + + + public + mixed + APP_TENANT_ID + = $hostd[0]->uuid @@ -337,9 +387,9 @@

@@ -348,7 +398,7 @@

public mixed IS_MULTITENANT - = false + = true @@ -374,7 +424,7 @@

@@ -424,7 +474,7 @@

@@ -462,7 +512,7 @@

@@ -532,7 +582,7 @@

@@ -574,7 +624,7 @@

@@ -614,7 +664,7 @@

- wpc_app(string $app_path[, string $options = 'app' ][, null|array<string|int, mixed> $tenant_ids = null ]) : BaseKernel + wpc_app(string $app_path[, string $options = 'app' ]) : BaseKernel

Optionally supports a multi-tenant configuration based on environment variables.

@@ -638,15 +688,6 @@

Parameters

The configuration filename, defaults to 'app'.

- -
- $tenant_ids - : null|array<string|int, mixed> - = null
-
-

Optional array of tenant IDs for multi-tenant support.

-
-
@@ -668,7 +709,7 @@

@@ -696,7 +737,7 @@

@@ -739,7 +780,7 @@

@@ -782,7 +823,7 @@

@@ -862,7 +903,7 @@

@@ -938,7 +979,7 @@

helpers.php : - 292 + 308 @@ -966,7 +1007,7 @@

@@ -1003,6 +1044,34 @@

Return values
+
+
+

+ env_tenant_id() + +

+ + + + + + env_tenant_id() : string|null + +
+ + + + +
Return values
+ string|null + — + +

@@ -1012,7 +1081,7 @@

@@ -1052,6 +1121,49 @@

Return values
— +
+
+

+ sclean_sensitive_env() + +

+ + +

Cleans up sensitive environment variables.

+ + + + sclean_sensitive_env(array<string|int, mixed> $sensitives) : void + +

This function removes specified environment variables from the $_ENV superglobal +and the environment to help secure sensitive information.

+
+ +
Parameters
+
+
+ $sensitives + : array<string|int, mixed> +
+
+

An array of environment variable names to be cleaned up.

+
+ +
+
+ + + +
Return values
+ void + — + +
diff --git a/docs/code/reports/markers.html b/docs/code/reports/markers.html index afce585..e3ed84f 100644 --- a/docs/code/reports/markers.html +++ b/docs/code/reports/markers.html @@ -96,32 +96,10 @@

Fil
diff --git a/docs/multi-tenant/index.md b/docs/multi-tenant/index.md index 784b383..e58d061 100644 --- a/docs/multi-tenant/index.md +++ b/docs/multi-tenant/index.md @@ -4,7 +4,7 @@ Before making any changes, ensure you have a full backup of your WordPress files and database. -Install and activate the [Tenancy plugin](#), this will create the required tables on the main site ( referred to as the Landlord site ). +Install and activate the [Tenancy plugin](#), this will create the required database tables and admin area on the main site ( referred to as the Landlord site ). ### Step 2: Enable Multi-Tenant in `wp-config.php` @@ -20,7 +20,7 @@ To properly set up the Landlord environment for your multi-tenant application in 1. **Backup Your Existing Environment File**: Before making any changes, it's crucial to back up your current `.env` file. -2. **Create a New `.env` File**: In the root directory of application installation, create a new `.env` file. This file will store the environment-specific configurations for the Landlord database. +2. **Create a New `.env` File**: In the root directory of application installation, create a new `.env` file. This file will store the environment-specific configurations for the Landlord database (settings in this env file are discarded after initial setup of the Landlord). 3. **Configure Landlord Database Settings**: Inside the newly created `.env` file, input the following configuration settings. These settings should match those of the main site (also referred to as the Landlord site) where the Tenancy plugin is installed. Adjust the values to reflect your specific Landlord database credentials: @@ -40,23 +40,10 @@ This document provides a comprehensive guide to the architecture and operational ## Domain and Tenant Mapping - Tenants are uniquely identified by a Universal Unique Identifier (UUID). -- The mapping between a tenant's domain (derived from HTTP_HOST) and its UUID is crucial. For instance: - -`example.com => a345ea9515c` - - > This mapping is typically configured in `bootstrap.php`. Refer to the env app for more details: [Env App Bootstrap](https://github.com/devuri/wp-env-app/blob/main/bootstrap.php) - -```php -// 'app' parameter is mandatory for configuration. -$http_app = wpc_app(__DIR__, 'app', ['example.com' => 'a345ea9515c']); -``` +- The mapping between a tenant's domain (derived from HTTP_HOST) and its UUID is crucial. ## Installation Steps -1. Prepare the `.env` file for each tenant, including essential variables like `APP_TENANT_ID=a345ea9515c` and `IS_MULTITENANT=true`. - - > Ensure each tenant's `.env` file is configured accordingly. - > **Note**: The uploads directory will be set to `/public/app/tenant/a345ea9515c/uploads`. Make sure to transfer or replicate your site files to this new directory. This setup uses the `tenant_id` for isolated file storage per tenant. ## Configuration and Environment Files @@ -88,14 +75,13 @@ This approach ensures a balance between customization for individual tenants and ## Tenant-Specific Variables -- Each tenant's `.env` file contains specific environment variables, such as: +- Each tenant's `.env` file can contain specific environment variables, such as: - `APP_TENANT_ID=a345ea9515c` - - `IS_MULTITENANT=true` - Optionally, `APP_TENANT_SECRET` for additional security. ## Customizing Tenant Configurations -- Utilize `env('APP_TENANT_ID')` within the application to access and modify configurations dynamically for each tenant. +- Utilize `env('APP_TENANT_ID')` within the application to access and modify configurations dynamically for each tenant. It is also set as `APP_TENANT_ID` constant during initialization steps. ## Isolated Uploads Directory @@ -110,7 +96,7 @@ This approach ensures a balance between customization for individual tenants and ## Plugin and Theme Management - An MU (Must-Use) plugin controls the availability of specific plugins and themes for each tenant. -- The `IS_MULTITENANT` variable aids in configuring resource availability and is particularly useful during tenant migrations or when converting a tenant to a standalone installation. +- The `IS_MULTITENANT` constant aids in configuring resource availability and is particularly useful during tenant migrations or when converting a tenant to a standalone installation. ## Suitability for Multi-Tenant Architecture diff --git a/tests/Unit/ScleanSensitiveEnvTest.php b/tests/Unit/ScleanSensitiveEnvTest.php new file mode 100644 index 0000000..2a55345 --- /dev/null +++ b/tests/Unit/ScleanSensitiveEnvTest.php @@ -0,0 +1,39 @@ +assertEquals('dummyvalue1', getenv('TEST_VAR1')); + $this->assertEquals('dummyvalue2', $_ENV['TEST_VAR2'] ?? null); + + // Call the function to clean up the specified + sclean_sensitive_env(['TEST_VAR1', 'TEST_VAR2']); + + // Verify that the environment variables have been unset + $this->assertEmpty(getenv('TEST_VAR1')); + $this->assertArrayNotHasKey('TEST_VAR2', $_ENV); + } +} diff --git a/tests/stubs.php b/tests/stubs.php index 102020d..479abc6 100644 --- a/tests/stubs.php +++ b/tests/stubs.php @@ -17,3 +17,4 @@ define( 'WPINC', true ); define('APP_TEST_PATH', __DIR__ ); define( 'WEBAPP_ENCRYPTION_KEY', APP_TEST_PATH . '/.secret.txt' ); +define( 'ABSPATH', APP_TEST_PATH . '/wp' );