Commit 0ad7f5db authored by James Lopez's avatar James Lopez

update license checks for audit events

parent a1434b1c
......@@ -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
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment