A comprehensive IP whitelist addon for Statamic CMS that provides robust access control for your control panel and custom routes.
Features
- π‘οΈ Control Panel Protection - Automatically protects Statamic CP routes
- π¨ Dark/Light Mode Support - Seamless integration with Statamic's theme system
- πΎ Flexible Storage - Choose between file-based or database storage
- π Advanced IP Matching - Supports CIDR notation, wildcards, and exact matches
- β‘ Artisan Commands - Manage whitelist via command line
- π§ Configurable Routes - Protect additional custom routes
- π Local Development Bypass - Optional bypass for local environments
- π Beautiful Interface - Modern, responsive control panel interface
Installation
-
composer require stokoe/ip-whitelist -
Publish the configuration file:
php artisan vendor:publish --tag=ip-whitelist-config
- Run migrations (if using database storage):
php artisan migrate
- Configure your settings in
config/ip-whitelist.php
Configuration
Storage Options
Choose between file or database storage:
// File storage (default)'storage' => 'file', // Database storage'storage' => 'database', // Don't forget to run the migrations!
Protected Routes
Add additional routes to protect:
'protected_routes' => [ 'admin/*', 'api/admin/*', 'custom-admin/*',],
Local Development
Bypass whitelist in local environment:
'bypass_local' => true, // Set to false to enforce in local
Usage
Control Panel Interface
- Navigate to Tools > IP Whitelist in the Statamic control panel
- Add, edit, or remove IP addresses through the intuitive interface
- View statistics and current IP information
Artisan Commands
Add an IP address:
php artisan ip-whitelist:manage add 192.168.1.100 --name="Office Network"
Remove an IP address:
php artisan ip-whitelist:manage remove 192.168.1.100
List all whitelisted IPs:
php artisan ip-whitelist:manage list
IP Address Formats
The addon supports multiple IP address formats:
- Exact IP:
192.168.1.100 - CIDR Notation:
192.168.1.0/24 - Wildcards:
192.168.1.*(Allows 192.168.1.1, 192.168.1.2, [...], 192.168.1.255)
Permissions
The addon creates a manage ip whitelist permission. Assign this to users who should be able to manage the IP whitelist.
Security Considerations
- Always add your current IP before enabling the whitelist
- Test access from different locations before deploying
- Consider using CIDR notation for office networks
File Storage Location
When using file storage, IP addresses are stored in:
storage/app/ip-whitelist.json
Database Storage
When using database storage, IP addresses are stored in the whitelisted_ips table with the following structure:
id- Primary keyip- IP address or patternname- Optional descriptionactive- Boolean statususer_id- The ID of the user who added the IPcreated_at/updated_at- Timestamps
Troubleshooting
Locked Out of Control Panel
If you're locked out:
- Add your IP via Artisan command:
php artisan ip-whitelist:manage add YOUR_IP_ADDRESS
-
Or temporarily disable the middleware by setting
bypass_localtotruein local environment (Only works in local dev) -
Or directly edit the storage file/database to add your IP
Local Development Issues
Ensure bypass_local is set to true in your configuration for local development.
Support
For issues or feature requests, please check the addon documentation or raise a Github issue.