For login allow list add support for IPv6 by tsteur · Pull Request #18046 · matomo-org/matomo · GitHub
Skip to content
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

Merged
merged 3 commits into from
Sep 23, 2021
Merged

For login allow list add support for IPv6 #18046

merged 3 commits into from
Sep 23, 2021

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Sep 22, 2021

Description:

Not sure why we didn't add this directly. see also faq https://matomo.org/faq/how-to/faq_25543/

Review

@@ -166,8 +166,15 @@
$ipsResolved[] = $ip;
} else {
$ipFromHost = @gethostbyname($ip);
if (!empty($ipFromHost)) {
if (!empty($ipFromHost)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the extra filter var check is needed as ipFromHost will be the hostname if it couldn't resolve it.

image

@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Sep 22, 2021
@tsteur tsteur added this to the 4.5.0 milestone Sep 22, 2021
@@ -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']);
Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Findus23 @sgiehl would it be an issue that https://integration-test.matomo.org/ resolves aaaa to ::1?

Copy link
Member

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

@tsteur tsteur added the Needs Review PRs that need a code review label Sep 22, 2021
$ipsResolved[] = $ipFromHost;
} elseif (function_exists('dns_get_record')) {
Copy link
Member

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?

@tsteur tsteur removed the Needs Review PRs that need a code review label Sep 22, 2021
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());
Copy link
Member Author

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

@tsteur tsteur added the Needs Review PRs that need a code review label Sep 23, 2021
Copy link
Member

@sgiehl sgiehl left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants