Commit 9682501f authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'shl-log-ip-address' into 'master'

Log current IP address of request that tries to access an IP restricted group

See merge request gitlab-org/gitlab!21392
parents 35f1701e d387f897
...@@ -7,6 +7,10 @@ module Gitlab ...@@ -7,6 +7,10 @@ module Gitlab
@group = group @group = group
end end
def logger
@logger ||= Gitlab::AuthLogger.build
end
def allows_current_ip? def allows_current_ip?
return true unless group&.feature_available?(:group_ip_restriction) return true unless group&.feature_available?(:group_ip_restriction)
...@@ -26,7 +30,11 @@ module Gitlab ...@@ -26,7 +30,11 @@ module Gitlab
return true unless root_ancestor_ip_restrictions.present? return true unless root_ancestor_ip_restrictions.present?
root_ancestor_ip_restrictions.any? { |ip_restriction| ip_restriction.allows_address?(address) } allowed = root_ancestor_ip_restrictions.any? { |ip_restriction| ip_restriction.allows_address?(address) }
logger.info(message: 'Attempting to access IP restricted group', group_full_path: group.full_path, ip_address: address, allowed: allowed)
allowed
end end
end end
end 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