🔐 n8n Workflow FortiGate: cấp quyền Internet theo giờ (Node-by-Node)
📅 Cập nhật: 23/03/2026🧪 Mức: Thực chiến Production🛡️ Đã ẩn toàn bộ thông tin nhạy cảm
1) Tổng quan workflow
Workflow này tự động hóa quy trình cấp quyền truy cập Internet tạm thời cho user theo form yêu cầu, với đầy đủ vòng đời Create → Enforce → Notify → Wait → Cleanup.
Tạo group cloud, add user theo email.
Clone profile bảo mật trên FortiGate theo template.
Tạo schedule theo giờ bắt đầu/kết thúc và tạo firewall policy.
Đến giờ hết hạn: tự xóa policy/schedule/profile/group + deauth user session.
Gửi email thông báo và lưu log Data Table để audit.
Điểm mạnh: giảm thao tác tay, giảm lỗi người vận hành, có kiểm soát và truy vết đầy đủ.
2) Sơ đồ workflow chi tiết
Hình thực tế workflow trong n8n Editor (đã làm mờ thông tin nhạy cảm).
Form Trigger
└─ Random code1 → HTTP Request Token (Graph)
└─ Tạo Group → get user id1 → ADD User vào group
└─ create group fortigate
└─ Code in JavaScript1 → Date & Time1 → Fortinet create time1
└─ If1
├─ Nhánh A (không_có): create rule → move rule
└─ Nhánh B (có ứng dụng):
Get app_web
├─ clone aplication profile → Get entries → create/get/update entries
└─ clone web profile
Merge → Random code_rule → create rule fortigate → move rule
└─ Fortigate get rule → Send a message1 → Insert row
└─ Wait (đến giờ kết thúc)
└─ delete rule → delete schedule → delete app/web profile
└─ delete fortigate group → delete azure group
└─ monitor firewall user → if active → deauth
└─ Send a message2
3) JSON mẫu đã sanitize (public-safe)
Ví dụ một số đoạn endpoint/secret đã được thay bằng placeholder: