Sivvy IP Protection - Example Integration
✓ This page demonstrates how to protect resources using Sivvy's IP allowlist.
How to Use
To protect your PHP pages with Sivvy:
- Get your API key from the Sivvy dashboard
- Include the protection functions at the top of your PHP file
- Call
protectPage($apiKey)
before any output
Basic Implementation
<?php
// Include the Sivvy protection functions
require_once 'sivvy-protection.php';
// Your API key from Sivvy dashboard
$apiKey = getenv('SIVVY_API_KEY');
// Protect this page
protectPage($apiKey);
// Your protected content here
?>
WordPress Integration
// In your theme's functions.php or a custom plugin
add_action('init', function() {
$apiKey = get_option('sivvy_api_key');
// Protect wp-admin
if (is_admin() && !wp_doing_ajax()) {
protectPage($apiKey);
}
// Or protect specific pages
if (is_page('sensitive-content')) {
protectPage($apiKey);
}
});
Laravel Integration
// Create a middleware
namespace App\Http\Middleware;
class SivvyIPProtection
{
public function handle($request, $next)
{
$apiKey = config('services.sivvy.api_key');
if (!$this->isIPAllowed($request->ip(), $apiKey)) {
return redirect('/blocked');
}
return $next($request);
}
}
// Apply to routes
Route::middleware(['sivvy.ip'])->group(function () {
Route::get('/admin', 'AdminController@index');
});
Your IP: 216.73.216.146
Status: This is a demo page (protection not active)
Advanced Options
- Caching: Cache the allowed IP list for better performance
- Webhooks: Get notified when IPs are blocked
- Custom blocked page: Customize the blocked message and styling
- Fail open/closed: Decide behavior when API is unavailable