Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
08586a61
Commit
08586a61
authored
Mar 23, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Audit log for deploy keys
parent
fbaf39ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
app/controllers/projects/deploy_keys_controller.rb
app/controllers/projects/deploy_keys_controller.rb
+9
-0
app/services/audit_event_service.rb
app/services/audit_event_service.rb
+24
-0
No files found.
app/controllers/projects/deploy_keys_controller.rb
View file @
08586a61
...
...
@@ -25,6 +25,8 @@ class Projects::DeployKeysController < Projects::ApplicationController
@key
=
DeployKey
.
new
(
deploy_key_params
)
if
@key
.
valid?
&&
@project
.
deploy_keys
<<
@key
log_audit_event
(
@key
.
title
,
action: :create
)
redirect_to
namespace_project_deploy_keys_path
(
@project
.
namespace
,
@project
)
else
...
...
@@ -36,6 +38,8 @@ class Projects::DeployKeysController < Projects::ApplicationController
@key
=
@project
.
deploy_keys
.
find
(
params
[
:id
])
@key
.
destroy
log_audit_event
(
@key
.
title
,
action: :destroy
)
respond_to
do
|
format
|
format
.
html
{
redirect_to
namespace_project_deploy_keys_path
(
@project
.
namespace
,
@project
)
}
format
.
js
{
render
nothing:
true
}
...
...
@@ -65,4 +69,9 @@ class Projects::DeployKeysController < Projects::ApplicationController
def
deploy_key_params
params
.
require
(
:deploy_key
).
permit
(
:key
,
:title
)
end
def
log_audit_event
(
key_title
,
options
=
{})
AuditEventService
.
new
(
current_user
,
@project
,
options
).
for_deploy_key
(
key_title
).
security_event
end
end
app/services/audit_event_service.rb
View file @
08586a61
...
...
@@ -40,6 +40,30 @@ class AuditEventService
self
end
def
for_deploy_key
(
key_title
)
action
=
@details
[
:action
]
@details
=
case
action
when
:destroy
{
remove:
"deploy_key"
,
target_id:
key_title
,
target_type:
"DeployKey"
,
target_details:
key_title
,
}
when
:create
{
add:
"deploy_key"
,
target_id:
key_title
,
target_type:
"DeployKey"
,
target_details:
key_title
,
}
end
self
end
def
security_event
SecurityEvent
.
create
(
author_id:
@author
.
id
,
...
...
Write
Preview
Markdown
is supported
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