Drupal 10 Module that provides a Context Condition that checks the user's IP address, and a Context Reaction that denies access to nodes and media. If the Reaction executes, it returns a 403 Access Denied response to the user (or optionally redirect them to a proxy to authenticate before accessing the resource).
This module's primary use case was to provide IP access control to Islandora content, but it can be used without Islandora.
- Clone this repo into your Islandora's
drupal/web/modules/contrib
directory. - Enable the module either under the "Admin > Extend" menu or by running
drush en -y ip_range_access
.
The Condition and Reaction are independent of each other (Context FTW!) but if your intent is to block a user from accessing content based on their IP address, do the following:
- Create a Context and choose the "User's IP address" Condition.
- Enter the ranges or individual IP addresses from where access is prohibited.
- (Optional) Add additional Conditions ("Node has parent", "Node has term", "User role", etc.). You probably want to add the "User's Role" condition to make sure that administrators aren't blocked from accessing content.
- Choose the "Deny access to node or media" Reaction and check the box.
- (Optional) Add the URL of a proxy, such as Ezproxy, to the reaction's configuration, e.g.,
https://proxy.example.com/login?url=
.
- (Optional) Add the URL of a proxy, such as Ezproxy, to the reaction's configuration, e.g.,
See issue list.
Bug reports, improvements, feature requests, and PRs welcome. Before you open a pull request, please open an issue.