Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require __DIR__ . '/vendor/autoload.php';
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
/////////////////////////
/// AUTHENTICATION
// Preparation
// Auth
// Should happen in CustomAuthenticationListener
/*
$providers = [new \BiiG\SecurityTest\CustomAuthenticationProvider()];
$authenticationManager = new \Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager($providers);
$authenticatedToken = $authenticationManager->authenticate($unauthenticatedToken);
//*/
///////////////////////
/// 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
$listeners = [new \BiiG\SecurityTest\CustomAuthenticationListener(
$tokenStorage,
new \BiiG\SecurityTest\CustomAuthenticationProvider(),
'swagg'
)];
$anonymousClass = \Symfony\Component\Security\Core\Authentication\Token\AnonymousToken::class;
$rememberMeClass = \Symfony\Component\Security\Core\Authentication\Token\RememberMeToken::class;
$trustResolver = new \Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver($anonymousClass, $rememberMeClass);
// 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);