-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For login allow list add support for IPv6 #18046
Conversation
config/global.php
Outdated
@@ -166,8 +166,15 @@ | |||
$ipsResolved[] = $ip; | |||
} else { | |||
$ipFromHost = @gethostbyname($ip); | |||
if (!empty($ipFromHost)) { | |||
if (!empty($ipFromHost) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -135,6 +135,12 @@ public function test_getAllowlistedLoginIps_shouldResolveIp() | |||
$this->assertSame(['192.168.33.1', '185.31.40.177', '127.0.0.1'], $this->allowlist->getAllowlistedLoginIps()); | |||
} | |||
|
|||
public function test_getAllowlistedLoginIps_shouldResolveIpv6() | |||
{ | |||
$this->setGeneralConfig('login_allowlist_ip', ['192.168.33.1', 'integration-test.matomo.org', '127.0.0.1']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added this DNS entry specifically for this test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't think of any reason why that could be an issue
config/global.php
Outdated
$ipsResolved[] = $ipFromHost; | ||
} elseif (function_exists('dns_get_record')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it generally make sense to do always both. A lookup for IPv4 and IPv6. I guess a hostname could actually resolve both, right?
public function test_getAllowlistedLoginIps_shouldResolveIpv6Only() | ||
{ | ||
$this->setGeneralConfig('login_allowlist_ip', ['192.168.33.1', 'integration-test.matomo.org', '127.0.0.1']); | ||
$this->assertSame(['192.168.33.1', 'integration-test.matomo.org', '::1', '127.0.0.1'], $this->allowlist->getAllowlistedLoginIps()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it may not be expected that it returns the integration test hostname here, but it was already doing it before so it shouldn't be a problem. Only fixing the IPv6 part for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test failures seem random, so guess this should be good to merge.
Description:
Not sure why we didn't add this directly. see also faq https://matomo.org/faq/how-to/faq_25543/
Review