🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 16:43
This commit is contained in:
@@ -25,6 +25,22 @@ final class AuthMiddleware
|
||||
|
||||
try {
|
||||
$decoded = $this->jwtService->verifyToken($token);
|
||||
|
||||
// Check if JTI is blacklisted
|
||||
$jti = $decoded['jti'] ?? null;
|
||||
if ($jti) {
|
||||
try {
|
||||
$redis = \App\Core\Redis::getInstance();
|
||||
if ($redis->exists('jwt_blacklist:' . $jti)) {
|
||||
Response::error('الجلسة منتهية، يرجى تسجيل الدخول من جديد', 'TOKEN_REVOKED', 401);
|
||||
return null;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// Redis down — allow (fail open, log security event)
|
||||
error_log('[AUTH] JWT blacklist check failed: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$request->user = (object) $decoded;
|
||||
$request->tenantId = $decoded['tenant_id'] ?? null;
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user