PHP code example of inqaba-security / gatekeeper

1. Go to this page and download the library: Download inqaba-security/gatekeeper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

inqaba-security / gatekeeper example snippets


// bootstrap/app.php (Laravel 11+)
->withMiddleware(function (Middleware $middleware) {
    $middleware->prepend(\Inqaba\Gatekeeper\Http\Middleware\BlockDeniedIps::class);
    $middleware->web(append: [
        \Inqaba\Gatekeeper\Http\Middleware\DetectEndpointAbuse::class,
        \Inqaba\Gatekeeper\Http\Middleware\ScanRequestThreats::class,
    ]);
})

'paths' => [
    'wp-login.php',
    'internal/photos/{id}',   // params are captured in the event context
    ['path' => 'legacy/export/{file}', 'methods' => ['GET'], 'where' => ['file' => '.*\.sql']],
],

Route::post('/register', ...)->middleware('siem.honeypot');

Route::get('/photos/{photo}', [PhotoController::class, 'show'])
    ->middleware('siem.enum');

use Inqaba\Gatekeeper\Facades\Siem;
use Inqaba\Gatekeeper\Events\{EventType, Severity};

// One-liner
Siem::log('export_download', 'Customer data export downloaded', Severity::High, [
    'rows' => 12000,
], $request->user());

// Fluent builder with a catalog type
Siem::event(EventType::AccessDenied)
    ->user($request->user())
    ->fromRequest($request)
    ->with(['ability' => 'orders.export'])
    ->report();

Siem::extend('kafka', fn ($app) => new KafkaSink(...));
// config/siem.php: 'active' => ['kafka'],

Siem::blockIp('203.0.113.7', minutes: 120, reason: 'analyst-decision');
Siem::unblockIp('203.0.113.7');
Siem::blocklist()->isBlocked('203.0.113.7');
bash
php artisan siem:test            # all active sinks
php artisan siem:test --sink=sentinel