Reading Authentication & Login Logs
Logging & Log Analysis
Chapter 5 · Reading Authentication & Login Logs
"A user can't log in" has been this course's own running example since Chapter 1. This chapter finally works through it properly — not as one problem, but as four genuinely different layers a request passes through, each with its own log source, each capable of being the actual point of failure.
The Diagnostic Order: Outside In
| Layer | What could go wrong here | Where it shows up |
|---|---|---|
| 1. Network/perimeter | The request never reaches this server at all | Nowhere on this server — Chapter 1's own "silent failure" applies directly |
| 2. Blocked before the app | Firewall, rate limiting, or a tool like fail2ban rejects the request first | fail2ban's own log, or a 401/403 in the access log with no matching application log entry at all |
| 3. Application-level auth | Wrong credentials, locked/disabled account, expired session | The application's own log, plus auth.log/secure from Chapter 3 |
| 4. Post-authentication | Login succeeds, but something afterward breaks (redirect, session storage) | A successful auth entry, immediately followed by an unrelated-looking error elsewhere |
Working outside-in matters: checking layer 3 first, when the real problem is layer 2, means reading application logs that were never going to show anything, because the request never reached the application to log anything at all.
Layer 1: Never Reaching the Server
If a user reports being unable to log in and nothing in any log on this server — not the access log, not the error log, not the application's own log — shows any trace of a request from them at all, the request most likely never arrived. A DNS problem, a network routing issue, or a client-side connectivity problem on the user's own end can all produce exactly this symptom. This server's own logs, by definition, cannot record a request that never reached it.
Layer 2: Blocked Before the Application
A very common real-world tool here is fail2ban, which watches logs (often auth.log itself) for repeated failed attempts and automatically firewalls off the offending IP for a period of time. Its own actions are logged separately:
Once banned, that IP's later requests are rejected at the firewall — before Apache or Nginx ever sees them, meaning they won't appear in the access log either. A legitimate user who mistyped their password a few times too many can end up banned by exactly the same mechanism meant to stop an attacker; fail2ban-client status <jail> (or the ban log itself) is how you tell the two apart.
A softer version of the same layer: HTTP basic authentication configured directly on the web server (via .htaccess or an equivalent) rejects a request with a 401 before the application underneath ever runs — this does appear in the access log, just without any corresponding application-level log entry.
Layer 3: Authentication Failing in the Application
This is the layer most people assume is the whole problem, and it does cover the most common real causes:
- Wrong credentials — routine, per Chapter 2's own example; logged at INFO, not ERROR, in a well-configured application
- Account locked or disabled — a deliberate security feature after too many failed attempts on one specific account, distinct from fail2ban's IP-level ban
- Account doesn't exist — a typo'd username, or a genuinely deleted/never-created account
- Session or token expired — the user was previously logged in, but their session has since lapsed
Layer 4: Authenticated Successfully, Then Something Breaks
The rarest but most confusing case: the application's own log shows a genuinely successful authentication, but the user still ends up unable to log in — because something after that succeeded step fails. A session store that's unreachable (Redis down, disk full for file-based sessions) or a broken post-login redirect are both real examples. The tell is a successful auth log line immediately followed by an apparently unrelated error somewhere else in the same request's timeframe — exactly the kind of cross-log correlation Chapter 4 introduced.
Hands-On Exercises
A user says they can't log in, but there's no trace of their request anywhere in the access log, error log, or application log. Explain what this chapter says is the most likely explanation, and why the application's own logs couldn't have shown anything different.
📄 View solutionExplain the difference between an IP being banned by fail2ban and a single account being locked after too many failed attempts, and why checking application logs first would be the wrong order for diagnosing the fail2ban case.
📄 View solutionExplain why failed logins across many different usernames from the same source IP are treated differently in this chapter than repeated failed logins on a single user's own account, and what each pattern most likely indicates.
📄 View solutionChapter 5 Quick Reference
- "Can't log in" is four layers, diagnosed outside-in: network/perimeter → blocked before the app (fail2ban, basic auth) → application-level auth → post-authentication breakage
- If nothing appears in any log, the request likely never reached the server at all — this server's logs can't record what it never received
- fail2ban bans an IP after repeated failures; once banned, later requests won't even reach the access log
- Wrong credentials are routine (INFO); account lockouts and session/token expiry are the other common application-level causes
- Same account repeatedly, same source — routine. Many accounts, same source — a real security pattern worth escalating
- A successful auth entry followed by an unrelated-looking error is Layer 4 — something broke after login succeeded, not during it
- Next chapter: Diagnosing "It's Slow" — A Log-Based Troubleshooting Walkthrough