Skip to content

Commit

Permalink
Fix audit logging when not using MFA (#32)
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Gaß <[email protected]>
  • Loading branch information
mxey authored and Luzifer committed Jan 17, 2019
1 parent 3650ad6 commit 085a158
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,16 @@ func handleLoginRequest(res http.ResponseWriter, r *http.Request) {
user, mfaCfgs, err := loginUser(res, r)
switch err {
case errNoValidUserFound:
auditFields["reason"] = "invalid credentials"
mainCfg.AuditLog.Log(auditEventLoginFailure, r, auditFields) // #nosec G104 - This is only logging
http.Redirect(res, r, "/login?go="+url.QueryEscape(r.FormValue("go")), http.StatusFound)
return
case nil:
// Don't handle for now, MFA validation comes first
default:
auditFields["reason"] = "error"
auditFields["error"] = err.Error()
mainCfg.AuditLog.Log(auditEventLoginFailure, r, auditFields) // #nosec G104 - This is only logging
log.WithError(err).Error("Login failed with unexpected error")
http.Redirect(res, r, "/login?go="+url.QueryEscape(r.FormValue("go")), http.StatusFound)
return
Expand Down

0 comments on commit 085a158

Please sign in to comment.