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
752579fb
Commit
752579fb
authored
Sep 15, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update audit event service to log password reset events
parent
8d5fa833
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
22 deletions
+49
-22
app/controllers/passwords_controller.rb
app/controllers/passwords_controller.rb
+12
-0
ee/app/services/ee/audit_event_service.rb
ee/app/services/ee/audit_event_service.rb
+37
-22
No files found.
app/controllers/passwords_controller.rb
View file @
752579fb
...
...
@@ -2,6 +2,7 @@ class PasswordsController < Devise::PasswordsController
before_action
:resource_from_email
,
only:
[
:create
]
before_action
:prevent_ldap_reset
,
only:
[
:create
]
before_action
:throttle_reset
,
only:
[
:create
]
before_action
:log_audit_event
,
only:
[
:create
]
def
edit
super
...
...
@@ -53,4 +54,15 @@ class PasswordsController < Devise::PasswordsController
redirect_to
new_user_session_path
,
notice:
I18n
.
t
(
'devise.passwords.send_paranoid_instructions'
)
end
private
def
log_audit_event
AuditEventService
.
new
(
current_user
,
resource
,
action: :custom
,
custom_message:
'Ask for password reset'
,
ip_address:
request
.
remote_ip
)
.
for_user
(
resource_params
[
:email
]).
unauth_security_event
end
end
ee/app/services/ee/audit_event_service.rb
View file @
752579fb
...
...
@@ -80,7 +80,7 @@ module EE
end
def
add_security_event_admin_details!
@details
.
merge!
(
ip_address:
@author
.
current_sign_in_ip
,
@details
.
merge!
(
ip_address:
ip_address
,
entity_path:
@entity
.
full_path
)
end
...
...
@@ -97,11 +97,13 @@ module EE
def
unauth_security_event
return
unless
audit_events_enabled?
@details
.
delete
(
:ip_address
)
unless
admin_audit_log_enabled?
@details
[
:entity_path
]
=
@entity
&
.
full_path
SecurityEvent
.
create
(
author_id:
-
1
,
entity_id:
-
1
,
author_id:
@author
&
.
id
||
-
1
,
entity_id:
@entity
&
.
id
||
-
1
,
entity_type:
'User'
,
details:
@details
)
...
...
@@ -121,15 +123,15 @@ module EE
def
for_custom_model
(
model
,
key_title
)
action
=
@details
[
:action
]
author_name
=
@author
.
name
model_class
=
model
.
camelize
custom_message
=
@details
[
:custom_message
]
@details
=
case
action
when
:destroy
{
remove:
model
,
author_name:
author_
name
,
author_name:
@author
.
name
,
target_id:
key_title
,
target_type:
model_class
,
target_details:
key_title
...
...
@@ -137,14 +139,27 @@ module EE
when
:create
{
add:
model
,
author_name:
author_
name
,
author_name:
@author
.
name
,
target_id:
key_title
,
target_type:
model_class
,
target_details:
key_title
}
when
:custom
{
custom_message:
custom_message
,
author_name:
@author
&
.
name
,
target_id:
key_title
,
target_type:
model_class
,
target_details:
key_title
,
ip_address:
@details
[
:ip_address
]
}
end
self
end
def
ip_address
@author
&
.
current_sign_in_ip
||
@details
[
:ip_address
]
end
end
end
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