Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Bob Public Utils
bobgroup-go-utils
Commits
b40201d3
Commit
b40201d3
authored
3 years ago
by
Jan Semmelink
Browse files
Options
Downloads
Patches
Plain Diff
Put username back in api-logs, so both user_id and username is logged
parent
d8a15727
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
logs/api-logs.go
+5
-0
5 additions, 0 deletions
logs/api-logs.go
with
5 additions
and
0 deletions
logs/api-logs.go
+
5
−
0
View file @
b40201d3
...
...
@@ -66,6 +66,7 @@ func LogIncomingAPIRequest(startTime time.Time, requestID string, claim map[stri
}
userID
,
_
:=
claim
[
"UserID"
]
.
(
int64
)
username
,
_
:=
claim
[
"Username"
]
.
(
string
)
accountID
,
_
:=
claim
[
"AccountID"
]
.
(
int64
)
if
accountID
==
0
{
if
accountIDParam
,
ok
:=
req
.
QueryStringParameters
[
"account_id"
];
ok
{
...
...
@@ -89,6 +90,7 @@ func LogIncomingAPIRequest(startTime time.Time, requestID string, claim map[stri
SourceIP
:
req
.
RequestContext
.
Identity
.
SourceIP
,
UserAgent
:
req
.
RequestContext
.
Identity
.
UserAgent
,
UserID
:
userID
,
Username
:
username
,
AccountID
:
accountID
,
Request
:
ApiLogRequest
{
Headers
:
req
.
Headers
,
...
...
@@ -149,6 +151,7 @@ func LogOutgoingAPIRequest(startTime time.Time, requestID string, claim map[stri
endTime
:=
time
.
Now
()
userID
,
_
:=
claim
[
"UserID"
]
.
(
int64
)
username
,
_
:=
claim
[
"Username"
]
.
(
string
)
accountID
,
_
:=
claim
[
"AccountID"
]
.
(
int64
)
params
:=
map
[
string
]
string
{}
parsedURL
,
err
:=
url
.
Parse
(
urlString
)
...
...
@@ -169,6 +172,7 @@ func LogOutgoingAPIRequest(startTime time.Time, requestID string, claim map[stri
ResponseCode
:
responseCode
,
RequestID
:
requestID
,
UserID
:
userID
,
Username
:
username
,
AccountID
:
accountID
,
Request
:
ApiLogRequest
{
//Headers: req.Headers,
...
...
@@ -219,6 +223,7 @@ type ApiLog struct {
InitialAuthType
string
`json:"initial_auth_type,omitempty"`
AccountID
int64
`json:"account_id,omitempty"`
UserID
int64
`json:"user_id,omitempty"`
Username
string
`json:"username,omitempty"`
SourceIP
string
`json:"source_ip,omitempty"`
//only logged for incoming API
UserAgent
string
`json:"user_agent,omitempty"`
//only for incoming, indicate type of browser when UI
RelevantID
string
`json:"relevant_id,omitempty"`
...
...
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