Skip to content
Snippets Groups Projects
foo.php 1.27 KiB
Newer Older
  • Learn to ignore specific revisions
  • Maxime Veber's avatar
    Maxime Veber committed
    <?php
    
    require __DIR__ . '/vendor/autoload.php';
    
    
    $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
    $dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
    
    
    ///////////////////////
    /// FIREWALL
    
    $map = new \Symfony\Component\Security\Http\FirewallMap();
    
    $requestMatcher = new \Symfony\Component\HttpFoundation\RequestMatcher('^/');
    
    $tokenStorage = new \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage();
    
    // instances of Symfony\Component\Security\Http\Firewall\ListenerInterface
    
    Maxime Veber's avatar
    Maxime Veber committed
    $listeners = [
        new \BiiG\SecurityTest\CustomAuthenticationListener(
            $tokenStorage,
            new \BiiG\SecurityTest\CustomAuthenticationProvider(),
            'swagg'
        )
    ];
    
    Maxime Veber's avatar
    Maxime Veber committed
    
    // The exception listener object is too complex for this example
    /*
    $exceptionListener = new \Symfony\Component\Security\Http\Firewall\ExceptionListener($tokenStorage, $trustResolver);
    //*/
    
    $map->add($requestMatcher, $listeners);
    
    
    $firewall = new \Symfony\Component\Security\Http\Firewall($map, $dispatcher);
    
    
    $dispatcher->addListener(
        \Symfony\Component\HttpKernel\KernelEvents::REQUEST,
        array($firewall, 'onKernelRequest')
    );
    
    $kernel = new \BiiG\SecurityTest\Kernel($dispatcher, function() {
        echo "<h1>Hello</h1>";
    });
    
    $kernel->handle($request);