Firewall authentication: the user, not the IP
This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.
Key points
- When a user group is added to a policy, traffic passes only for authenticated members of that group. Both the address and the group must match.
- Active authentication: the FortiGate asks the user for a name and password. The prompt can be shown only in HTTP, HTTPS, FTP and Telnet traffic.
- Passive authentication: the user is asked nothing; the identity is learned from another source (for example a domain logon with FSSO).
- The ordering trap: if a policy without authentication that matches the same traffic is higher up, the FortiGate never asks for a password.
- Authentication is temporary: an idle user must log in again after auth-timeout (5 minutes by default).
Why is the IP not enough?
Writing a policy that says "10.10.10.50–59 is accounting" works until an accountant takes a laptop to another room or DHCP gives it a different address. An IP identifies a device, not a person.
A user-based policy says: "members of the accounting group may open the banking site, whichever computer they sit at". On top of that the logs show a name, not an IP.
Local users and groups
The simplest case: users are stored on the FortiGate itself.
FGT-HQ # config user local FGT-HQ (local) # edit "isci01" FGT-HQ (isci01) # set type password FGT-HQ (isci01) # set passwd <password> FGT-HQ (isci01) # next FGT-HQ (local) # end FGT-HQ # config user group FGT-HQ (group) # edit "MUHASIBAT-GRP" FGT-HQ (MUHASIBAT-GRP) # set member "isci01" FGT-HQ (MUHASIBAT-GRP) # next FGT-HQ (group) # end
GUI: User & Authentication > User Definition and User Groups.
Always use a group in a policy, not a single user. When a new employee arrives you add them to the group and do not touch the policy.
Local users suit a small office or guest access. In a company with dozens of staff the accounts already exist in Active Directory and need not be created again on the FortiGate (lesson 23).
Adding a group to a policy
FGT-HQ # config firewall policy FGT-HQ (policy) # edit 5 FGT-HQ (5) # set name "MUHASIBAT-to-WAN" FGT-HQ (5) # set srcintf "port2" FGT-HQ (5) # set dstintf "port1" FGT-HQ (5) # set srcaddr "LAN-NET" FGT-HQ (5) # set dstaddr "all" FGT-HQ (5) # set groups "MUHASIBAT-GRP" FGT-HQ (5) # set schedule "always" FGT-HQ (5) # set service "HTTP" "HTTPS" "DNS" FGT-HQ (5) # set action accept FGT-HQ (5) # set nat enable FGT-HQ (5) # next FGT-HQ (policy) # end
In the GUI you add the group from the User section to the Source field, next to the address.
The policy now reads: the source address is in LAN-NET and the user is a member of MUHASIBAT-GRP.
How active authentication works
- A staff member opens a site in the browser.
- The packet matches policy 5 (ports, address, service), but the FortiGate does not know who is behind this IP.
- The FortiGate intercepts the request and shows a login page in the browser.
- The user types a name and password. The FortiGate checks them and keeps an
IP → user → groupsentry in memory. - From then on all traffic from that IP counts as this user.
An important limitation: the login page can be shown only in HTTP, HTTPS, FTP and Telnet traffic. If a user turns on the computer and starts the mail client straight away, the FortiGate can show nothing and the traffic simply does not pass. The user has to open a browser and log in first.
Three classic traps
1. A policy without authentication above. The FortiGate reads policies top-down. If a policy that matches the same traffic and requires no group is higher up, the traffic lands there and the login page never appears.
| Order | Policy | Result |
|---|---|---|
| 1 | LAN → internet, no group | Everyone passes, nobody is asked for a password |
| 2 | LAN → internet, MUHASIBAT-GRP | Never used |
Policies with authentication must be at the top.
2. DNS. For the login page to appear the browser first has to resolve the site name. If DNS traffic does not pass, the browser never sends a request. So add DNS to the services of the authentication policy.
3. HTTPS and the certificate. When the user opens an HTTPS site the FortiGate has to step in and show the login page, and the browser gives a certificate warning. The solution: assign a trusted certificate to the login page (config user setting → set auth-cert).
Captive portal
The method above works at policy level. A captive portal works at interface level: everyone arriving on that port must log in first. It is the typical choice for guest Wi-Fi.
FGT-HQ # config system interface FGT-HQ (interface) # edit "VLAN20" FGT-HQ (VLAN20) # set security-mode captive-portal FGT-HQ (VLAN20) # set security-groups "Guest-group" FGT-HQ (VLAN20) # next FGT-HQ (interface) # end
Timeouts
FGT-HQ # config user setting FGT-HQ (setting) # set auth-timeout 30 FGT-HQ (setting) # set auth-timeout-type idle-timeout FGT-HQ (setting) # end
| Type | When it expires |
|---|---|
idle-timeout (default) | When no traffic comes from the user for this many minutes |
hard-timeout | This many minutes after login, regardless of activity |
new-session | When no new session is opened |
The default of 5 idle minutes is very short: a user who comes back from a tea break has to type the password again. Most people set it to 30–480 minutes.
Who is logged in?
FGT-HQ # diagnose firewall auth list FGT-HQ # diagnose firewall auth clear
The first command shows logged-in users, their IPs, groups and the time left. The second logs everyone out (useful while testing). GUI: Dashboard > Users & Devices > Firewall Users; there you can log out a single user.
Watch out on a real device: active authentication is tiring for staff and does not work on devices that cannot type a password, such as servers, printers and phones. Write a separate address-based policy for them. In a domain network a passive method (FSSO, lesson 24) is more comfortable for staff: they notice nothing.
🧪 Hands-on lab · Device: FortiGate-VM
User, group and a group-based policy
Create a local user isci01 (set type password, any password). Create a group called MUHASIBAT-GRP and make isci01 a member. Then add this group to policy 1 (set groups). From then on the policy works only for authenticated members of the group.
Checked:
- User isci01
- Group MUHASIBAT-GRP: isci01
- Policy 1: groups MUHASIBAT-GRP
Check yourself
5 questions · answers are shown instantly · 3 correct answers complete the lesson
1A policy has both srcaddr and a user group. When does traffic pass?
2In which traffic can the login page be shown with active authentication?
3Above a policy that requires a group there is a policy without a group matching the same traffic. What happens?
4With an authentication policy the login page never appears and the browser says "site not found". What is the most likely cause?
5idle-timeout is 5 minutes. When must the user log in again?
Comments
Sign in to comment.