GWM : app signature and relationship string in getEmployeePolicy API
This commit is contained in:
parent
125af14d1c
commit
933dfb2f5a
@ -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',
|
||||
],
|
||||
|
||||
@ -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);
|
||||
|
||||
36
app/Filters/VerifyAppSignature.php
Normal file
36
app/Filters/VerifyAppSignature.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filters;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Filters\FilterInterface;
|
||||
|
||||
class VerifyAppSignature implements FilterInterface
|
||||
{
|
||||
public function before(RequestInterface $request, $arguments = null)
|
||||
{
|
||||
// Get the header sent by the Flutter app
|
||||
$clientSignature = $request->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
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user