update
This commit is contained in:
@@ -7,4 +7,16 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
* Header `x-access-token` như portal-client gửi (xem ClientAccessTokenCheck).
|
||||
*/
|
||||
protected function buildClientAccessToken(?int $timestamp = null, ?string $ip = null): string
|
||||
{
|
||||
$key = hex2bin((string) config('services.client_api.key'));
|
||||
$payload = ['s' => (string) config('services.client_api.secret'), 't' => $timestamp ?? time()] + ($ip ? ['ip' => $ip] : []);
|
||||
$iv = random_bytes(16);
|
||||
|
||||
return base64_encode($iv . openssl_encrypt(json_encode($payload), 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user