Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
usermetadb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
id
usermetadb
Commits
56cbd40b
Commit
56cbd40b
authored
2 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Add authenticator ID field to the userlog
parent
7c1d2d27
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
protocol.go
+8
-7
8 additions, 7 deletions
protocol.go
server/sql.go
+3
-0
3 additions, 0 deletions
server/sql.go
server/userlog.go
+7
-5
7 additions, 5 deletions
server/userlog.go
server/userlog_test.go
+1
-0
1 addition, 0 deletions
server/userlog_test.go
with
19 additions
and
12 deletions
protocol.go
+
8
−
7
View file @
56cbd40b
...
...
@@ -66,13 +66,14 @@ func DecodeDeviceInfoFromMap(m map[string]string, prefix string) *DeviceInfo {
// LogEntry represents an authentication event in the user-specific log.
type
LogEntry
struct
{
Timestamp
time
.
Time
`json:"timestamp"`
Username
string
`json:"username"`
Type
string
`json:"log_type"`
Message
string
`json:"message,omitempty"`
Service
string
`json:"service,omitempty"`
LoginMethod
string
`json:"login_method,omitempty"`
DeviceInfo
*
DeviceInfo
`json:"device_info,omitempty"`
Timestamp
time
.
Time
`json:"timestamp"`
Username
string
`json:"username"`
Type
string
`json:"log_type"`
Message
string
`json:"message,omitempty"`
Service
string
`json:"service,omitempty"`
LoginMethod
string
`json:"login_method,omitempty"`
LoginAuthenticatorID
string
`json:"login_authenticator_id,omitempty"`
DeviceInfo
*
DeviceInfo
`json:"device_info,omitempty"`
}
func
(
e
*
LogEntry
)
Validate
()
error
{
...
...
This diff is collapsed.
Click to expand it.
server/sql.go
+
3
−
0
View file @
56cbd40b
...
...
@@ -85,6 +85,9 @@ INSERT INTO userlog (username, service, log_type, login_method, message, device_
DROP TABLE _userlog_old;
`
,
`
PRAGMA foreign_keys=on;
`
),
sqlutil
.
Statement
(
`
ALTER TABLE userlog ADD COLUMN login_authenticator_id TEXT;
`
),
}
...
...
This diff is collapsed.
Click to expand it.
server/userlog.go
+
7
−
5
View file @
56cbd40b
...
...
@@ -42,17 +42,17 @@ var userlogDBStatements = map[string]string{
// optional device information).
"insert_userlog"
:
`
INSERT INTO userlog (
username, service, log_type, login_method, message, timestamp
username, service, log_type, login_method,
login_authenticator_id,
message, timestamp
) VALUES (
?, ?, ?, ?, ?, ?
?, ?, ?, ?, ?, ?
, ?
)`
,
"insert_userlog_with_device_info"
:
`
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_browser, device_os, device_mobile
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
, ?
)`
,
// Database maintenance (prune old entries etc).
...
...
@@ -87,7 +87,7 @@ var userlogDBStatements = map[string]string{
// Retrieve logs for a specific user.
"get_user_logs"
:
`
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_browser, device_os, device_mobile
FROM
...
...
@@ -229,6 +229,7 @@ func (u *userlogDB) AddLog(ctx context.Context, entry *usermetadb.LogEntry) erro
entry
.
Service
,
entry
.
Type
,
entry
.
LoginMethod
,
entry
.
LoginAuthenticatorID
,
entry
.
Message
,
entry
.
Timestamp
,
}
...
...
@@ -285,6 +286,7 @@ func scanEntryRow(rows *sql.Rows) (*usermetadb.LogEntry, error) {
&
e
.
Service
,
&
e
.
Type
,
&
e
.
LoginMethod
,
&
e
.
LoginAuthenticatorID
,
&
e
.
Message
,
&
e
.
Timestamp
,
&
deviceID
,
...
...
This diff is collapsed.
Click to expand it.
server/userlog_test.go
+
1
−
0
View file @
56cbd40b
...
...
@@ -127,6 +127,7 @@ func bulkLoadTestLogs(t testing.TB, db *sql.DB) *usermetadb.LogEntry {
entry
.
Service
,
entry
.
Type
,
entry
.
LoginMethod
,
entry
.
LoginAuthenticatorID
,
entry
.
Message
,
entry
.
Timestamp
,
entry
.
DeviceInfo
.
ID
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment