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
0ad7f5db
Commit
0ad7f5db
authored
Sep 19, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update license checks for audit events
parent
a1434b1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
17 deletions
+24
-17
ee/app/services/ee/audit_event_service.rb
ee/app/services/ee/audit_event_service.rb
+20
-17
spec/ee/spec/services/ee/audit_event_service_spec.rb
spec/ee/spec/services/ee/audit_event_service_spec.rb
+4
-0
No files found.
ee/app/services/ee/audit_event_service.rb
View file @
0ad7f5db
...
...
@@ -76,29 +76,14 @@ module EE
return
super
end
super
if
audit_events_enabled?
end
def
add_security_event_admin_details!
@details
.
merge!
(
ip_address:
ip_address
,
entity_path:
@entity
.
full_path
)
end
def
audit_events_enabled?
return
true
unless
@entity
.
respond_to?
(
:feature_available?
)
@entity
.
feature_available?
(
:audit_events
)
end
def
admin_audit_log_enabled?
License
.
feature_available?
(
:admin_audit_log
)
super
if
audit_events_enabled?
||
entity_audit_events_enabled?
end
def
unauth_security_event
return
unless
audit_events_enabled?
@details
.
delete
(
:ip_address
)
unless
admin_audit_log_enabled?
@details
[
:entity_path
]
=
@entity
&
.
full_path
@details
[
:entity_path
]
=
@entity
&
.
full_path
if
admin_audit_log_enabled?
SecurityEvent
.
create
(
author_id:
@author
.
respond_to?
(
:id
)
?
@author
.
id
:
-
1
,
...
...
@@ -160,5 +145,23 @@ module EE
def
ip_address
@author
&
.
current_sign_in_ip
||
@details
[
:ip_address
]
end
def
add_security_event_admin_details!
@details
.
merge!
(
ip_address:
ip_address
,
entity_path:
@entity
.
full_path
)
end
def
entity_audit_events_enabled?
@entity
.
respond_to?
(
:feature_available?
)
&&
@entity
.
feature_available?
(
:audit_events
)
end
def
audit_events_enabled?
# Always log auth events. Log all other events if `extended_audit_events` is enabled
@details
[
:with
]
||
License
.
feature_available?
(
:extended_audit_events
)
end
def
admin_audit_log_enabled?
License
.
feature_available?
(
:admin_audit_log
)
end
end
end
spec/ee/spec/services/ee/audit_event_service_spec.rb
View file @
0ad7f5db
...
...
@@ -7,6 +7,10 @@ describe AuditEventService do
let
(
:service
)
{
described_class
.
new
(
author_name
,
nil
,
ip_address:
ip_address
)
}
let
(
:event
)
{
service
.
for_failed_login
.
unauth_security_event
}
before
do
stub_licensed_features
(
extended_audit_events:
true
)
end
it
'has the right type'
do
expect
(
event
.
entity_type
).
to
eq
(
'User'
)
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