change token method & remove error page
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>401 – Accès non autorisé</title>
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
body {
|
||||
font-family: ui-sans-serif, system-ui, sans-serif;
|
||||
background: #f8fafc;
|
||||
color: #1e293b;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
padding: 2.5rem 3rem;
|
||||
max-width: 420px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
box-shadow: 0 4px 24px rgba(0,0,0,.06);
|
||||
}
|
||||
|
||||
.code {
|
||||
font-size: 4rem;
|
||||
font-weight: 700;
|
||||
color: #e11d48;
|
||||
line-height: 1;
|
||||
margin-bottom: .5rem;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: .75rem;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: .95rem;
|
||||
color: #64748b;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<div class="code">401</div>
|
||||
<h1>Accès non autorisé</h1>
|
||||
<p>{{ $exception->getMessage() ?: 'Vous n\'êtes pas autorisé à accéder à cette ressource.' }}</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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