feat: harden admin auth and ticket workflows

- add rotating admin refresh tokens and password gates\n- expand ticket galleries, exports, and client resources\n- improve IP allocation auditing and dashboard data\n- enforce encrypted client access tokens on public routes
This commit is contained in:
baodev0
2026-10-16 17:00:55 +07:00
parent 0cdf224309
commit 0b08689ea4
52 changed files with 1421 additions and 118 deletions
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api\Admin\IpPool\Concerns;
use App\Models\Customer;
use App\Models\IpPool;
use App\Models\IpPoolLog;
use App\Services\IpPool\IpAllocationService;
use App\Support\MailAttachments;
use Illuminate\Http\JsonResponse;
@@ -55,6 +56,45 @@ trait ManagesIpPoolAllocation
]);
}
public function allLogs(Request $request): JsonResponse
{
$data = $request->validate([
'filter' => 'nullable|string|max:255',
'action' => 'nullable|array',
'action.*' => 'in:' . implode(',', [IpPoolLog::ALLOCATED, IpPoolLog::REVOKED, IpPoolLog::VM_ASSIGNED, IpPoolLog::VM_RELEASED]),
'date_from' => 'nullable|date',
'date_to' => 'nullable|date',
'per_page' => 'nullable|integer|min:1|max:100',
]);
$paginator = IpPoolLog::with('user:id,username,fullname')
->when($data['filter'] ?? null, function ($query, string $filter) {
$like = '%' . addcslashes($filter, '%_\\') . '%';
$query->where(fn ($q) => $q->where('ip_address', 'like', $like)
->orWhere('customer_name', 'like', $like)
->orWhere('service_name', 'like', $like)
->orWhere('vm_name', 'like', $like)
->orWhere('email_to', 'like', $like)
->orWhere('email_cc', 'like', $like)
->orWhere('email_bcc', 'like', $like));
})
->when($data['action'] ?? null, fn ($query, array $actions) => $query->whereIn('action', $actions))
->when($data['date_from'] ?? null, fn ($query, string $from) => $query->whereDate('created_at', '>=', $from))
->when($data['date_to'] ?? null, fn ($query, string $to) => $query->whereDate('created_at', '<=', $to))
->latest('id')
->paginate($data['per_page'] ?? 20);
return response()->json([
'error' => false,
'data' => [
'items' => $paginator->items(),
'total' => $paginator->total(),
'per_page' => $paginator->perPage(),
'current_page' => $paginator->currentPage(),
],
]);
}
private function validateAllocation(Request $request): array
{
return $request->validate([