Skip to content
Snippets Groups Projects
Commit 56cbd40b authored by ale's avatar ale
Browse files

Add authenticator ID field to the userlog

parent 7c1d2d27
No related branches found
No related tags found
No related merge requests found
...@@ -72,6 +72,7 @@ type LogEntry struct { ...@@ -72,6 +72,7 @@ type LogEntry struct {
Message string `json:"message,omitempty"` Message string `json:"message,omitempty"`
Service string `json:"service,omitempty"` Service string `json:"service,omitempty"`
LoginMethod string `json:"login_method,omitempty"` LoginMethod string `json:"login_method,omitempty"`
LoginAuthenticatorID string `json:"login_authenticator_id,omitempty"`
DeviceInfo *DeviceInfo `json:"device_info,omitempty"` DeviceInfo *DeviceInfo `json:"device_info,omitempty"`
} }
......
...@@ -85,6 +85,9 @@ INSERT INTO userlog (username, service, log_type, login_method, message, device_ ...@@ -85,6 +85,9 @@ INSERT INTO userlog (username, service, log_type, login_method, message, device_
DROP TABLE _userlog_old; DROP TABLE _userlog_old;
`, ` `, `
PRAGMA foreign_keys=on; PRAGMA foreign_keys=on;
`),
sqlutil.Statement(`
ALTER TABLE userlog ADD COLUMN login_authenticator_id TEXT;
`), `),
} }
......
...@@ -42,17 +42,17 @@ var userlogDBStatements = map[string]string{ ...@@ -42,17 +42,17 @@ var userlogDBStatements = map[string]string{
// optional device information). // optional device information).
"insert_userlog": ` "insert_userlog": `
INSERT INTO userlog ( INSERT INTO userlog (
username, service, log_type, login_method, message, timestamp username, service, log_type, login_method, login_authenticator_id, message, timestamp
) VALUES ( ) VALUES (
?, ?, ?, ?, ?, ? ?, ?, ?, ?, ?, ?, ?
)`, )`,
"insert_userlog_with_device_info": ` "insert_userlog_with_device_info": `
INSERT INTO userlog ( INSERT INTO userlog (
username, service, log_type, login_method, message, timestamp, username, service, log_type, login_method, login_authenticator_id, message, timestamp,
device_id, device_remote_zone, device_user_agent, device_id, device_remote_zone, device_user_agent,
device_browser, device_os, device_mobile device_browser, device_os, device_mobile
) VALUES ( ) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)`, )`,
// Database maintenance (prune old entries etc). // Database maintenance (prune old entries etc).
...@@ -87,7 +87,7 @@ var userlogDBStatements = map[string]string{ ...@@ -87,7 +87,7 @@ var userlogDBStatements = map[string]string{
// Retrieve logs for a specific user. // Retrieve logs for a specific user.
"get_user_logs": ` "get_user_logs": `
SELECT SELECT
service, log_type, login_method, message, timestamp, service, log_type, login_method, login_authenticator_id, message, timestamp,
device_id, device_remote_zone, device_user_agent, device_id, device_remote_zone, device_user_agent,
device_browser, device_os, device_mobile device_browser, device_os, device_mobile
FROM FROM
...@@ -229,6 +229,7 @@ func (u *userlogDB) AddLog(ctx context.Context, entry *usermetadb.LogEntry) erro ...@@ -229,6 +229,7 @@ func (u *userlogDB) AddLog(ctx context.Context, entry *usermetadb.LogEntry) erro
entry.Service, entry.Service,
entry.Type, entry.Type,
entry.LoginMethod, entry.LoginMethod,
entry.LoginAuthenticatorID,
entry.Message, entry.Message,
entry.Timestamp, entry.Timestamp,
} }
...@@ -285,6 +286,7 @@ func scanEntryRow(rows *sql.Rows) (*usermetadb.LogEntry, error) { ...@@ -285,6 +286,7 @@ func scanEntryRow(rows *sql.Rows) (*usermetadb.LogEntry, error) {
&e.Service, &e.Service,
&e.Type, &e.Type,
&e.LoginMethod, &e.LoginMethod,
&e.LoginAuthenticatorID,
&e.Message, &e.Message,
&e.Timestamp, &e.Timestamp,
&deviceID, &deviceID,
......
...@@ -127,6 +127,7 @@ func bulkLoadTestLogs(t testing.TB, db *sql.DB) *usermetadb.LogEntry { ...@@ -127,6 +127,7 @@ func bulkLoadTestLogs(t testing.TB, db *sql.DB) *usermetadb.LogEntry {
entry.Service, entry.Service,
entry.Type, entry.Type,
entry.LoginMethod, entry.LoginMethod,
entry.LoginAuthenticatorID,
entry.Message, entry.Message,
entry.Timestamp, entry.Timestamp,
entry.DeviceInfo.ID, entry.DeviceInfo.ID,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment