change token method & remove error page
This commit is contained in:
@@ -49,29 +49,14 @@ class DelegateAuthController extends Controller
|
||||
|
||||
private function decryptToken(string $token): ?array
|
||||
{
|
||||
if (!str_contains($token, ".")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
[$ivB64, $encrypted] = explode(".", $token, 2);
|
||||
|
||||
$iv = base64_decode($ivB64, strict: true);
|
||||
$key = substr(
|
||||
hash("sha256", config("delegate-auth.encrypt_key"), binary: true),
|
||||
$data = base64_decode(urldecode($token));
|
||||
$payload = openssl_decrypt(
|
||||
substr($data, 16),
|
||||
"AES-256-CBC",
|
||||
config("delegate.encrypt_key"),
|
||||
0,
|
||||
32,
|
||||
substr($data, 0, 16),
|
||||
);
|
||||
|
||||
if ($iv === false || strlen($iv) !== 16) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$payload = openssl_decrypt($encrypted, "AES-256-CBC", $key, 0, $iv);
|
||||
|
||||
if ($payload === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode($payload, associative: true);
|
||||
|
||||
return is_array($data) ? $data : null;
|
||||
|
||||
Reference in New Issue
Block a user