diff --git a/app/Config/Filters.php b/app/Config/Filters.php index 6d8514a..0909c51 100755 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -12,6 +12,7 @@ use CodeIgniter\Filters\SecureHeaders; use App\Filters\AuthMVC; use App\Filters\HttpRequestLog; use App\Filters\CloseDbConnection; +use App\Filters\VerifyAppSignature; use App\Filters\AuthJWT; use App\Filters\Cors; @@ -35,8 +36,9 @@ class Filters extends BaseConfig 'authMVC' => AuthMVC::class, 'HttpRequestLog' => HttpRequestLog::class, 'authJWT' => AuthJWT::class, - 'CloseDbConnection' => CloseDbConnection::class - 'Cors' => Cors::class + 'CloseDbConnection' => CloseDbConnection::class, + 'Cors' => Cors::class, + 'appSignature' => VerifyAppSignature::class, ]; /** @@ -54,7 +56,7 @@ class Filters extends BaseConfig // 'invalidchars', ], 'after' => [ - 'CloseDbConnection' + 'CloseDbConnection', 'Cors', // 'secureheaders', ], diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index c5db380..5517945 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -1347,6 +1347,7 @@ class EmployeeRestController extends AdminController $temp2['is_value_exist'] = false; $temp2['data']['family_floater_key'] = $familyFloatesValue; + $temp2['data']['relationship'] = ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue))); $temp2['data']['client_policy_id'] = $array->ClientPolicyId; $temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue))); $temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue); @@ -1556,6 +1557,7 @@ class EmployeeRestController extends AdminController $temp2['is_value_exist'] = false; $temp2['data']['family_floater_key'] = $familyFloatesValue; + $temp2['data']['relationship'] = ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue))); $temp2['data']['client_policy_id'] = $array->ClientPolicyId; $temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue))); $temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue); @@ -2100,6 +2102,7 @@ class EmployeeRestController extends AdminController $temp2['is_value_exist'] = false; $temp2['data']['family_floater_key'] = $familyFloatesValue; + $temp2['data']['relationship'] = ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue))); $temp2['data']['client_policy_id'] = $array['id']; $temp2['data']['button_name'] = 'Add '.ucfirst(str_replace('_', ' ', preg_replace('/\d/', '', $familyFloatesValue))); $temp2['data']['form_type'] = preg_replace('/\d/', '', $familyFloatesValue); diff --git a/app/Filters/VerifyAppSignature.php b/app/Filters/VerifyAppSignature.php new file mode 100644 index 0000000..a5257b2 --- /dev/null +++ b/app/Filters/VerifyAppSignature.php @@ -0,0 +1,36 @@ +getHeaderLine('App-Signature'); + + // Load the server's expected signature from the .env + $validSignature = getenv('APP_SIGNATURE'); + + // Check if signature is valid + if ($clientSignature !== $validSignature) { + return service('response') + ->setStatusCode(403) + ->setJSON([ + 'status' => false, + 'message' => 'Forbidden: Invalid App Signature', + ]); + } + + // allow request to proceed + } + + public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) + { + // nothing to do after response + } +}