Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ai3
accountserver
Commits
47b9f57e
Commit
47b9f57e
authored
Jul 01, 2018
by
ale
Browse files
Ensure we always log a user in audit logs
parent
11821eaf
Changes
2
Show whitespace changes
Inline
Side-by-side
actions.go
View file @
47b9f57e
...
@@ -159,6 +159,11 @@ type PasswordRecoveryRequest struct {
...
@@ -159,6 +159,11 @@ type PasswordRecoveryRequest struct {
Password
string
`json:"password"`
Password
string
`json:"password"`
}
}
// NewContext adds logging data to the current request context.
func
(
r
*
PasswordRecoveryRequest
)
NewContext
(
ctx
context
.
Context
)
context
.
Context
{
return
context
.
WithValue
(
ctx
,
userCtxKey
,
r
.
Username
)
}
// Validate the request.
// Validate the request.
func
(
r
*
PasswordRecoveryRequest
)
Validate
(
ctx
context
.
Context
,
s
*
AccountService
)
error
{
func
(
r
*
PasswordRecoveryRequest
)
Validate
(
ctx
context
.
Context
,
s
*
AccountService
)
error
{
return
s
.
fieldValidators
.
password
(
ctx
,
r
.
Password
)
return
s
.
fieldValidators
.
password
(
ctx
,
r
.
Password
)
...
@@ -782,6 +787,11 @@ type CreateUserRequest struct {
...
@@ -782,6 +787,11 @@ type CreateUserRequest struct {
User
*
User
`json:"user"`
User
*
User
`json:"user"`
}
}
// NewContext returns a new Context providing log context data.
func
(
req
*
CreateUserRequest
)
NewContext
(
ctx
context
.
Context
)
context
.
Context
{
return
context
.
WithValue
(
ctx
,
userCtxKey
,
req
.
User
.
Name
)
}
// ApplyTemplate fills in default values for the resources in the request.
// ApplyTemplate fills in default values for the resources in the request.
func
(
req
*
CreateUserRequest
)
ApplyTemplate
(
ctx
context
.
Context
,
tx
TX
,
s
*
AccountService
,
_
*
User
)
error
{
func
(
req
*
CreateUserRequest
)
ApplyTemplate
(
ctx
context
.
Context
,
tx
TX
,
s
*
AccountService
,
_
*
User
)
error
{
// Some fields should be unset because there are specific
// Some fields should be unset because there are specific
...
...
audit.go
View file @
47b9f57e
...
@@ -32,6 +32,9 @@ func (l *syslogAuditLogger) Log(ctx context.Context, resourceID ResourceID, what
...
@@ -32,6 +32,9 @@ func (l *syslogAuditLogger) Log(ctx context.Context, resourceID ResourceID, what
if
!
resourceID
.
Empty
()
{
if
!
resourceID
.
Empty
()
{
e
.
ResourceName
=
resourceID
.
Name
()
e
.
ResourceName
=
resourceID
.
Name
()
e
.
ResourceType
=
resourceID
.
Type
()
e
.
ResourceType
=
resourceID
.
Type
()
if
u
:=
resourceID
.
User
();
u
!=
""
{
e
.
User
=
u
}
}
}
data
,
_
:=
json
.
Marshal
(
&
e
)
data
,
_
:=
json
.
Marshal
(
&
e
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment