- Turnstile (App\Support\Turnstile, middleware turnstile) cho login admin và login/register/forgot/reset của khách; cấu hình ở setting key=turnstile, secret mã hoá SignRSA. - Menu sidebar khách (setting client_menu) và nút tắt topbar (setting client_quick_links) do admin sửa qua administrator/client-menu[/quick-links], khách đọc v1/setting/menu, v1/setting/quick-links. - v1/setting và settings/public chỉ trả whitelist PublicSetting::FIELDS (trước đây lộ bot_token, inet_api_key). - Cài đặt tài khoản khách (preferences), rate limit theo IP cho register/resend-verify. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
648 B
PHP
26 lines
648 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Support\Turnstile;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class VerifyTurnstile
|
|
{
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
if (!Turnstile::verify($request->input(Turnstile::TOKEN_FIELD), $request->ip())) {
|
|
return response()->json([
|
|
'error' => true,
|
|
'message' => 'Xác minh bảo mật (captcha) không hợp lệ hoặc đã hết hạn. Vui lòng thử lại.',
|
|
], 422);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|