Geoblock Registration

Geoblock Registration 1.1.2

No permission to download

Sim

Well-known member
Sim submitted a new resource:

Geoblock Registration - Registration Geoblocking using Maxmind's GeoLite2 Database

This XenForo 2.1 addon provides Geoblocking capabilities for user registration.

You can set allowed and denied lists for countries based on the IP address a user registers from - and optionally force users from non-approved countries into the moderation queue when registering.

The addon uses the free Maxmind GeoLite2 downloadable IP database to identify the country associated with the IP address of a registering user.

As an example, a typical use-case...

Read more about this resource...
 

Sim

Well-known member
What about Social network registration? Also check?

Thanks!

Yes, it should check social network registrations.

We register a new spam checker to validate users during registration. Connected account registration via social networks also performs spam checks - so this should check those users too - although I haven't explicitly tested it yet.
 
  • Like
Reactions: rdn

Sim

Well-known member
Note that database updates are likely broken right now due to changes recently implemented by Maxmind to comply with The California Consumer Privacy Act (CCPA) - https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/

Provided you already have a valid database downloaded, the Geoblocking should still work as expected.

I'm away from the office until the middle of January but once I am back, I will work on an update which will allow users to continue downloading the Maxmind GeoLite2 database. Note that this will require you to create a (free) account with Maxmind so that you can enter your username and API key to complete the download.
 

Ozzy47

Well-known member
I'm away from the office until the middle of January but once I am back, I will work on an update which will allow users to continue downloading the Maxmind GeoLite2 database. Note that this will require you to create a (free) account with Maxmind so that you can enter your username and API key to complete the download.

I would be most interested in what you come up with as the change has also affected two of my free addons.
 
  • Like
Reactions: Sim

Sim

Well-known member
v1.1.1 has been released with support for the new Maxmind GeoLite2 database download mechanism.

The magic all happens in the Hampel\Geoblock\Maxmind\DatabaseExtractor class, which you can view here: https://bitbucket.org/hampel/geoblock-xenforo/src/master/Maxmind/DatabaseExtractor.php

Given that I've MIT licensed the addon, other addon developers are welcome to utilise my class in their own addons - provided that the license file and copyright remains intact (indeed, it would be good if you included the copyright information directly in the class you create in your own namespace).

Full MIT license for the addon is here: https://bitbucket.org/hampel/geoblock-xenforo/src/master/LICENSE.md

Usage is pretty simple:

PHP:
$licenseKey = ''; // need to get this from config
$dbPath = 'maxmind/GeoLite2-Country.mmdb'; // relative to the internal_data directory ... you might want to make this a config option?

$extractor = new Hampel\Geoblock\Maxmind\DatabaseExtractor(\XF::app());

if (!$extractor->updateDatabase($licenseKey, $dbPath))
{
    \XF::logError("Maxmind database update failed");
}
 

Xon

Well-known member
I'm away from the office until the middle of January but once I am back, I will work on an update which will allow users to continue downloading the Maxmind GeoLite2 database. Note that this will require you to create a (free) account with Maxmind so that you can enter your username and API key to complete the download.
Supporting Cloudflare's GeoIP feature is also quite simple, it is an extra header they push down when someone connects via Clouldflare's proxy service
 

rdn

Well-known member
Is it possible you can add a new option to force all countries not on the white-list to only use Social registration?
Thanks!
 

Sim

Well-known member
Is it possible you can add a new option to force all countries not on the white-list to only use Social registration?
Thanks!

Hi @rdn - this is unlikely to be something I'll be adding at this point. Will consider it for future updates though - thanks for the suggestion.
 
  • Like
Reactions: rdn

Sim

Well-known member
Sim updated Geoblock Registration with a new update entry:

v1.1.2 update

No new functionality included in this release - just some code cleanup and unit testing. No need to upgrade from v1.1.1

  • check that vendor folder exists to prevent breaking forum if we somehow didn't run composer install
  • latest vendor dependencies
  • use mock mmdb database for unit testing testing
  • make subcontainer more testable by allowing paths to be replaced at runtime
  • verified compatibility with XF 2.2

Read the rest of this update entry...
 

Mouth

Well-known member
If you already have GeoLite2 db's on your server, updated regularly, can this addon be used without the Maxmind downloading ( just deactivate its cron task? ) and just copy/link the server's .mmdb into the relevant dir ( as specified, within internal_data/ ) ?
 

Sim

Well-known member
If you already have GeoLite2 db's on your server, updated regularly, can this addon be used without the Maxmind downloading ( just deactivate its cron task? ) and just copy/link the server's .mmdb into the relevant dir ( as specified, within internal_data/ ) ?

Yes, I don't see why that wouldn't work - exactly like you described. Disable cron task for database update, create a link to your existing .mmdb file somewhere in the internal_data directory and configure the options to point to that linked file.

The only gotcha might be if the Flysystem filesystem library doesn't like dealing with links.

It's worth testing though.
 

Mouth

Well-known member
Yes, I don't see why that wouldn't work - exactly like you described.
Works fine, with the exception that I needed to put a non-zero value within the license key field. With it empty/null or 0 it wouldn't work, but with a value of 1 or any other combination of characters, it worked great.
Thanks!
 
  • Like
Reactions: Sim

spyralout

Member
Sorry, mispost, that was for a different paid add on. I downloaded this for free on here, it was a mix up. When asked for the License Key, do I need to put something here? Thanks
 

Sim

Well-known member
Sorry, mispost, that was for a different paid add on. I downloaded this for free on here, it was a mix up. When asked for the License Key, do I need to put something here? Thanks

Yes, you need to put your MaxMind License Key for downloading GeoIP2 Lite database data - just like it says in the description.

Go to the MaxMind website and register for your free key.
 
Top