luci-base: log login attempts
authorJo-Philipp Wich <jo@mein.io>
Wed, 17 Jan 2018 17:49:08 +0000 (18:49 +0100)
committerJo-Philipp Wich <jo@mein.io>
Wed, 17 Jan 2018 17:49:42 +0000 (18:49 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/luasrc/dispatcher.lua

index e4f77f18d89d27cfcf525e5d40e5f08d905adfdb..16b32548e6f626b2928cb6b2589e26947494085d 100644 (file)
@@ -191,6 +191,9 @@ local function session_setup(user, pass, allowed_users)
                        timeout  = tonumber(luci.config.sauth.sessiontime)
                })
 
+               local rp = context.requestpath
+                       and table.concat(context.requestpath, "/") or ""
+
                if type(login) == "table" and
                   type(login.ubus_rpc_session) == "string"
                then
@@ -199,8 +202,14 @@ local function session_setup(user, pass, allowed_users)
                                values = { token = sys.uniqueid(16) }
                        })
 
+                       io.stderr:write("luci: accepted login on /%s for %s from %s\n"
+                               %{ rp, user, http.getenv("REMOTE_ADDR") or "?" })
+
                        return session_retrieve(login.ubus_rpc_session)
                end
+
+               io.stderr:write("luci: failed login on /%s for %s from %s\n"
+                       %{ rp, user, http.getenv("REMOTE_ADDR") or "?" })
        end
 
        return nil, nil
@@ -358,7 +367,7 @@ function dispatch(request)
                "https://github.com/openwrt/luci/issues"
        )
 
-       if track.sysauth then
+       if track.sysauth and not ctx.authsession then
                local authen = track.sysauth_authenticator
                local _, sid, sdat, default_user, allowed_users