Browse Source

Added webdav fail login log

TC pushbot 5 4 years ago
parent
commit
f5d7b73db7

+ 2 - 2
mod/auth/authlogger/authlogger.go

@@ -53,7 +53,7 @@ func (l *Logger) LogAuth(r *http.Request, loginStatus bool) error {
 }
 
 //Log the current authentication to record by custom filled information. Use LogAuth if your module is authenticating via web interface
-func (l *Logger) LogAuthByRequestInfo(username string, remoteAddr string, timestamp int64, loginSuceed bool, authType string) error {
+func (l *Logger) LogAuthByRequestInfo(username string, remoteAddr string, timestamp int64, loginSucceed bool, authType string) error {
 	//Get the current month as the table name, create table if not exists
 	current := time.Now().UTC()
 	tableName := current.Format("Jan-2006")
@@ -90,7 +90,7 @@ func (l *Logger) LogAuthByRequestInfo(username string, remoteAddr string, timest
 	thisRecord := LoginRecord{
 		Timestamp:      timestamp,
 		TargetUsername: username,
-		LoginSucceed:   loginSuceed,
+		LoginSucceed:   loginSucceed,
 		IpAddr:         remoteAddrInfo[0],
 		AuthType:       authType,
 		Port:           port,

+ 3 - 1
mod/storage/webdav/webdav.go

@@ -17,6 +17,7 @@ import (
 	"sort"
 	"strings"
 	"sync"
+	"time"
 
 	"imuslab.com/arozos/mod/network/webdav"
 	"imuslab.com/arozos/mod/user"
@@ -230,7 +231,8 @@ func (s *Server) HandleRequest(w http.ResponseWriter, r *http.Request) {
 	authAgent := s.userHandler.GetAuthAgent()
 	passwordValid := authAgent.ValidateUsernameAndPassword(username, password)
 	if !passwordValid {
-		log.Println("Someone try to log into " + username + " WebDAV endpoint with incorrect password")
+		authAgent.Logger.LogAuthByRequestInfo(username, r.RemoteAddr, time.Now().Unix(), false, "webdav")
+		log.Println("Someone from " + r.RemoteAddr + " try to log into " + username + " WebDAV endpoint with incorrect password")
 		http.Error(w, "Invalid username or password", http.StatusUnauthorized)
 		return
 	}

+ 14 - 0
web/SystemAO/security/connlog.html

@@ -40,6 +40,7 @@
                         <th>Timestamp</th>
                         <th>Requested Account</th>
                         <th>IP Address</th>
+                        <th>Connection Type</th>
                         <th>Access Port</th>
                     </tr>
                 </thead>
@@ -128,11 +129,24 @@
                                 if (entry.LoginSucceed == false){
                                     statusIcon = `<i class="red remove icon"></i>`;
                                 }
+
+                                var authType = entry.AuthType;
+                                if (authType == ""){
+                                    authType = "N/A"
+                                }else if (authType == "web"){
+                                    authType = `<i class="blue globe icon"></i> Web Interface`
+                                }else if (authType == "ftp"){
+                                    authType = `<i class="yellow folder icon"></i> FTP`
+                                }else if (authType == "webdav"){
+                                    authType = `<i class="blue folder icon"></i> WebDAV`
+                                }
+
                                 $("#records").append(`<tr>
                                     <td data-label="status">${statusIcon}</td>
                                     <td data-label="timestamp">${timestamp}</td>
                                     <td data-label="acc">${entry.TargetUsername}</td>
                                     <td data-label="ip">${entry.IpAddr}</td>
+                                    <td data-label="authtype">${authType}</td>
                                     <td data-label="port">${entry.Port}</td>
                                 </tr>`);
                             });