feat: update auth and security flow
This commit is contained in:
@@ -27,8 +27,40 @@ class Encryption extends BaseConfig
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$hex = (string) env('encryption.key', '');
|
||||
$hex = trim((string) env('encryption.key', ''));
|
||||
if (
|
||||
(str_starts_with($hex, "'") && str_ends_with($hex, "'"))
|
||||
|| (str_starts_with($hex, '"') && str_ends_with($hex, '"'))
|
||||
) {
|
||||
$hex = substr($hex, 1, -1);
|
||||
}
|
||||
$this->key = (strlen($hex) === 64 && ctype_xdigit($hex)) ? hex2bin($hex) : '';
|
||||
|
||||
$prev = trim((string) env('encryption.previousKeys', ''));
|
||||
if ($prev !== '') {
|
||||
$parsed = [];
|
||||
$parts = array_map('trim', explode(',', $prev));
|
||||
foreach ($parts as $part) {
|
||||
if ($part === '') {
|
||||
continue;
|
||||
}
|
||||
if (str_starts_with($part, 'hex2bin:')) {
|
||||
$part = substr($part, 8);
|
||||
}
|
||||
if (
|
||||
(str_starts_with($part, "'") && str_ends_with($part, "'"))
|
||||
|| (str_starts_with($part, '"') && str_ends_with($part, '"'))
|
||||
) {
|
||||
$part = substr($part, 1, -1);
|
||||
}
|
||||
if (strlen($part) === 64 && ctype_xdigit($part)) {
|
||||
$parsed[] = 'hex2bin:' . $part;
|
||||
}
|
||||
}
|
||||
if (! empty($parsed)) {
|
||||
$this->previousKeys = $parsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user