PHP code example of polaris / sentinel

1. Go to this page and download the library: Download polaris/sentinel 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/ */

    

polaris / sentinel example snippets


use Polaris\Admin\AdminPlugin;
use Polaris\Audit\AuditPlugin;
use Polaris\Sentinel\SentinelPlugin;

$polaris = Polaris::create(new Config(..., plugins: [new AuditPlugin(), new AdminPlugin(), new SentinelPlugin()]));

new SentinelPlugin(
    mode: SentinelPlugin::ENFORCE,
    policy: new Policy(challengeAt: 40, blockAt: 80),
    velocity: ['ip' => [20, 600], 'email' => [10, 600], 'device' => [30, 600]],   // limit, window seconds
    verifier: new TurnstileVerifier($httpClient, $requestFactory, $streamFactory, $secret),  // or HcaptchaVerifier
    geo: new MaxMindGeoResolver('/var/lib/GeoLite2-City.mmdb'),                   // needs maxmind-db/reader
    breachChecker: new HibpBreachChecker($httpClient, $requestFactory),
    disposableDomains: ['trash.example'],                                          // beside the bundled list
    disposableListFile: '/var/lib/polaris/disposable-domains.txt',                 // instead of the bundled file
    counters: new CacheCounterStore($redisCache, $clock),                          // any PSR-16 store; the graph's cache by default
    responses: $responseFactory,                                                   // PSR-17; discovered when omitted
    routes: [...SentinelMiddleware::ROUTES, '/auth/password/reset' => Attempt::PASSWORD_RESET],
    signals: [new MySignal()],
);