PHPackages                             steveworley/restrict - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. steveworley/restrict

ActiveDrupal-module[HTTP &amp; Networking](/categories/http)

steveworley/restrict
====================

Drupal 8 HTTP Middleware to handle IP and path restrictions

v1.0.0(9y ago)1151[1 issues](https://github.com/steveworley/restrict/issues)GPL2PHPPHP &gt;=5.4.0

Since Oct 12Pushed 9y agoCompare

[ Source](https://github.com/steveworley/restrict)[ Packagist](https://packagist.org/packages/steveworley/restrict)[ Docs](http://github.com/steveworley/restrict)[ RSS](/packages/steveworley-restrict/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Restrict
========

[](#restrict)

[![Build Status](https://camo.githubusercontent.com/abe232cb3beb58a852d7ec5e4d079192d324aaf3087e15ab8d0c3c40460e0cca/68747470733a2f2f7472617669732d63692e6f72672f7374657665776f726c65792f72657374726963742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/steveworley/restrict)

HTTP Middleware to handle IP and path restrictions.

Installation
------------

[](#installation)

### Composer

[](#composer)

`composer require drupal/restrict`

### Manual

[](#manual)

```
cd modules/custom
git clone --branch  git@github.com:steveworley/restrict.git

```

Configuration
-------------

[](#configuration)

All configuration for this module is managed via a sites `settings.php` file.

### Available options:

[](#available-options)

#### `$settings['restrict_whitelist'] Array`

[](#settingsrestrict_whitelist-array)

An array of IP addresses to allow on to the site that may use the following syntax:

- CIDR (107.0.255.128/27)
- Range (121.91.2.5-121-121.91.3.4)
- Wildcard (36.222.120.\*)
- Single (9.80.226.4)

```
$settings['restrict_whitelist'] = [
  '107.20.238.9',
  '70.102.97.2/30'
];
```

#### `$settings['restrict_blacklist'] Array`

[](#settingsrestrict_blacklist-array)

An array of IP addresses that will be denied access to the site that may use the following syntax:

- CIDR (107.0.255.128/27)
- Range (121.91.2.5-121-121.91.3.4)
- Wildcard (36.222.120.\*)
- Single (9.80.226.4)

```
$settings['restrict_blacklist'] = [
  '107.20.238.9',
  '70.102.97.2/30'
];
```

#### `$settings['restrict_basic_auth_credentials'] Array`

[](#settingsrestrict_basic_auth_credentials-array)

An array of basic auth username =&gt; password combinations.

```
$settings['restrict_basic_auth_credentials'] = [
  'Editor' => 'P455w0rd',
  'user' => 'password',
  ]
];
```

#### `$settings['restrict_restricted_paths'] Array`

[](#settingsrestrict_restricted_paths-array)

Paths which may not be accessed unless the user is on the IP whitelist. Paths should start with a leading '/'. Path restrictions can have options specified by an associative array.

```
$settings['restrict_restricted_paths'] = [
  '/path',
  '/path/to/restricted/resource',
  '/path' => [
    'auth' => ['username' => 'password'],
   ],
];
```

#### `$settings['restrict_response_code'] Int`

[](#settingsrestrict_response_code-int)

Returns a 404 instead of a 403 when users are denied. This should be set to a value from the `RestrictManager` class. Possible values:

- `RESTRICT_NOT_FOUND`
- `RESTRICT_UNAUTHORISED`
- `RESTRICT_FORBIDDEN`

```
$settings['restrict_response_code'] = 'RESTRICT_NOT_FOUND';
```

#### `$settings['restrict_trusted_proxies'] Array`

[](#settingsrestrict_trusted_proxies-array)

`restrict_trusted_proxies` ensures Acquia load balancers and their IPs are added to the trusted proxies list.

```
$settings['restrict_trusted_proxies'] = [
  '127.0.0.1',
];
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3496d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c8258df66e218beb23a6fde84e4df327f3789df3b6449e153d7ae6aa2b3fdcc?d=identicon)[steveworley](/maintainers/steveworley)

---

Top Contributors

[![steveworley](https://avatars.githubusercontent.com/u/1840912?v=4)](https://github.com/steveworley "steveworley (6 commits)")[![typhonius](https://avatars.githubusercontent.com/u/3642111?v=4)](https://github.com/typhonius "typhonius (1 commits)")

---

Tags

drupalblacklistrestrictwhitelist

### Embed Badge

![Health badge](/badges/steveworley-restrict/health.svg)

```
[![Health](https://phpackages.com/badges/steveworley-restrict/health.svg)](https://phpackages.com/packages/steveworley-restrict)
```

###  Alternatives

[pragmarx/firewall

A Laravel IP whitelisting and blacklisting

1.4k988.9k](/packages/pragmarx-firewall)[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23483.5k2](/packages/corveda-php-sandbox)[jaaulde/php-ipv4

PHP classes for working with IPV4 addresses and networks.

1034.6k](/packages/jaaulde-php-ipv4)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
