|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* Auth Module Bootstrap |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright (c) 2013-2015 Cross Solution (http://cross-solution.de) |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Auth; |
|
11
|
|
|
|
|
12
|
|
|
use Acl\Listener\CheckPermissionsListener; |
|
13
|
|
|
use Auth\Listener\SocialProfilesUnconfiguredErrorListener; |
|
14
|
|
|
use Zend\Mvc\MvcEvent; |
|
15
|
|
|
use Auth\View\InjectLoginInfoListener; |
|
16
|
|
|
use Auth\Listener\TokenListener; |
|
17
|
|
|
use Auth\Listener\UnauthorizedAccessListener; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Bootstrap class of the Core module |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
class Module |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
public function init(\Zend\ModuleManager\ModuleManagerInterface $moduleManager) |
|
27
|
|
|
{ |
|
28
|
|
|
if (\Zend\Console\Console::isConsole()) { |
|
29
|
|
|
return; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
$eventManager = $moduleManager->getEventManager()->getSharedManager(); |
|
33
|
|
|
$tokenListener = new TokenListener(); |
|
34
|
|
|
$tokenListener->attachShared($eventManager); |
|
35
|
|
|
} |
|
36
|
|
|
/** |
|
37
|
|
|
* Loads module specific configuration. |
|
38
|
|
|
* |
|
39
|
|
|
* @return array |
|
40
|
|
|
*/ |
|
41
|
|
|
public function getConfig() |
|
42
|
|
|
{ |
|
43
|
|
|
return include __DIR__ . '/config/module.config.php'; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Loads module specific autoloader configuration. |
|
48
|
|
|
* |
|
49
|
|
|
* @return array |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getAutoloaderConfig() |
|
52
|
|
|
{ |
|
53
|
|
|
|
|
54
|
|
|
return array( |
|
55
|
|
|
'Zend\Loader\ClassMapAutoloader' => array( |
|
56
|
|
|
// This is an hack due to bad design of Hybridauth |
|
57
|
|
|
// This ensures the class from "addtional-providers" is loaded. |
|
58
|
|
|
array( |
|
59
|
|
|
'Hybrid_Providers_XING' |
|
60
|
|
|
=> __DIR__ . '/../../vendor/hybridauth/hybridauth/additional-providers/hybridauth-xing/Providers/XING.php', |
|
61
|
|
|
), |
|
62
|
|
|
array( |
|
63
|
|
|
'Hybrid_Providers_Github' |
|
64
|
|
|
=> __DIR__ . '/../../vendor/hybridauth/hybridauth/additional-providers/hybridauth-github/Providers/GitHub.php', |
|
65
|
|
|
), |
|
66
|
|
|
), |
|
67
|
|
|
'Zend\Loader\StandardAutoloader' => array( |
|
68
|
|
|
'namespaces' => array( |
|
69
|
|
|
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, |
|
70
|
|
|
'AuthTest' => __DIR__ . '/test/AuthTest', |
|
71
|
|
|
'Acl' => __DIR__ . '/src/Acl', |
|
72
|
|
|
'AclTest' => __DIR__ . '/test/AclTest', |
|
73
|
|
|
), |
|
74
|
|
|
), |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function onBootstrap(MvcEvent $e) |
|
79
|
|
|
{ |
|
80
|
|
|
if (\Zend\Console\Console::isConsole()) { |
|
81
|
|
|
return; |
|
82
|
|
|
} |
|
83
|
|
|
$eventManager = $e->getApplication()->getEventManager(); |
|
84
|
|
|
$services = $e->getApplication()->getServiceManager(); |
|
85
|
|
|
|
|
86
|
|
|
$eventManager->attach( |
|
87
|
|
|
MvcEvent::EVENT_ROUTE, |
|
88
|
|
|
function (MvcEvent $e) use ($services) { |
|
89
|
|
|
/** @var CheckPermissionsListener $checkPermissionsListener */ |
|
90
|
|
|
$checkPermissionsListener = $services->get('Auth/CheckPermissionsListener'); |
|
91
|
|
|
$checkPermissionsListener->onRoute($e); |
|
92
|
|
|
}, |
|
93
|
|
|
-10 |
|
94
|
|
|
); |
|
95
|
|
|
|
|
96
|
|
|
$eventManager->attach( |
|
97
|
|
|
MvcEvent::EVENT_DISPATCH, |
|
98
|
|
|
function (MvcEvent $e) use ($services) { |
|
99
|
|
|
/** @var CheckPermissionsListener $checkPermissionsListener */ |
|
100
|
|
|
$checkPermissionsListener = $services->get('Auth/CheckPermissionsListener'); |
|
101
|
|
|
$checkPermissionsListener->onDispatch($e); |
|
102
|
|
|
}, |
|
103
|
|
|
10 |
|
104
|
|
|
); |
|
105
|
|
|
|
|
106
|
|
|
$unauthorizedAccessListener = $services->get('UnauthorizedAccessListener'); |
|
107
|
|
|
$unauthorizedAccessListener->attach($eventManager); |
|
108
|
|
|
|
|
109
|
|
|
$sharedManager = $eventManager->getSharedManager(); |
|
110
|
|
|
$defaultlistener = $services->get('Auth/Listener/AuthAggregateListener'); |
|
111
|
|
|
$defaultlistener->attachShared($sharedManager); |
|
112
|
|
|
|
|
113
|
|
|
$socialProfilesUnconfiguredErrorListener = new SocialProfilesUnconfiguredErrorListener(); |
|
114
|
|
|
$socialProfilesUnconfiguredErrorListener->attach($eventManager); |
|
115
|
|
|
|
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|