Restrict SilverStripe controllers to specific IP address
This module allows SilverStripe developers to restrict access to arbitrary-defined controllers, according to a User's IP address. Requests to specific Controllers will be denied if a user's IP does not match the provided list of allowed IP addresses.
Allowed IP addresses can be set via an environment variable or via the SiteConfig.
Common use cases of the module includes:
composer require internetrix/silverstripe-controller-ip-restriction
Internetrix\CMSAdminIPRestriction\AllowedIPMiddleware
in config:
In the following example, we are restricting access to the CMS admin as well as the /dev
controller.
Internetrix\CMSAdminIPRestriction\AllowedIPMiddleware:
enabled: true
restricted_controllers:
- SilverStripe\Admin\AdminRootController
- SilverStripe\Dev\DevelopmentAdmin
.env
file, using a SS_ADMIN_ALLOWED_IPS
variable. For multiple IP addresses, use a comma-limited list.SS_ADMIN_ALLOWED_IPS='123.0.0.1,248.1.1.1'
Allowed IPs
tab. Simply create a new record with an exact IP address and label it with the corresponding physical location (used for audit purposes)CanBypassIPRestriction
database field is set to true. This can be set when editing the member in the CMS and is only applied if the User remains a CMS Administrator.CanBypassIPRestriction
value for the user can be checked. If the CMS admin or another Controller is restricted, a user must first log-in to SilverStripe via a non-restricted page (i.e A Only Logged-in Users Can View Page) before the IP Bypass will be applied..env
or via the SiteConfig
, the restricted controllers will be inaccessible.Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem