2017 © Pedro Peláez
 

library php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

image

jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  • Friday, November 18, 2016
  • by Jalle19
  • Repository
  • 5 Watchers
  • 19 Stars
  • 55,036 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 6 Forks
  • 2 Open issues
  • 9 Versions
  • 13 % Grown

The README.md

Run test suite Coverage Status Scrutinizer Code Quality, (*1)

php-whitelist-check

A modern and simple approach to validating IP addresses and domains against a whitelist. It supports both IPv4 and IPv6 addresses and CIDR subnets in addition to domain names and wild-card domains., (*2)

Requirements

  • PHP 5.3 or newer

Usage

The Check::whitelist() method takes an array of definitions which will constitute the whitelist. The definitions can either be strings (which will be parsed to their respective objects) or objects., (*3)

The Check::check($value) method is used to check the specified value against the current whitelist. The method will return true if the value matches any of the definitions., (*4)

To create your own definition classes just extended Whitelist\Definition\Definition and implement Whitelist\Definition\IDefinition, (*5)

Example usage:, (*6)

require_once("vendor/autoload.php");

$checker = new Whitelist\Check();

try {
    $checker->whitelist(array(
        '10.0.3.1',
        '10.0.0.0/16',
        '2001:db8:100:934b::3:1',
        '2001:db8:100:934b::/64',
        '*.example.com',
        'localhost',
        new Whitelist\Definition\Domain('vpn.work.com'),
    ));
}
catch (InvalidArgumentException $e) {
    // thrown when an invalid definition is encountered
}

$checker->check('10.0.1.1'); // true
$checker->check('10.1.1.1'); // false
$checker->check('2001:db8:100:934b::210:2'); // true
$checker->check('another.example.com'); // true

License

This library is licensed under the BSD 2-Clause License, (*7)

Credits

This library depends on xrstf/ip-utils for the IP-related functionality. It also assumes that ip-utils's test cases are sufficient, which is why only trivial testing on these functions have been made for this library., (*8)

The Versions

18/11 2016

dev-master

9999999-dev https://github.com/Jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

ipv6 ipv4 whitelist cidr

18/11 2016

1.0.7

1.0.7.0 https://github.com/Jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

ipv6 ipv4 whitelist cidr

29/10 2015

1.0.6

1.0.6.0 https://github.com/Jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

ipv6 ipv4 whitelist cidr

02/10 2015

1.0.5

1.0.5.0 https://github.com/Jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

ipv6 ipv4 whitelist cidr

11/05 2014

1.0.4

1.0.4.0 https://github.com/Jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

ipv6 ipv4 whitelist cidr

05/02 2014

1.0.3

1.0.3.0 https://github.com/Jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

ipv6 ipv4 whitelist cidr

03/02 2014

1.0.2

1.0.2.0 https://github.com/Jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

ipv6 ipv4 whitelist cidr

03/02 2014

1.0.1

1.0.1.0 https://github.com/Jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

ipv6 ipv4 whitelist cidr

03/02 2014

1.0.0

1.0.0.0 https://github.com/Jalle19/php-whitelist-check

Provides a simple way to check whether an address or domain is on a whitelist

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

ipv6 ipv4 whitelist cidr