1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2012-2013 Andreas Heigl<[email protected]> |
4
|
|
|
* |
5
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
6
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
7
|
|
|
* in the Software without restriction, including without limitation the rights |
8
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
10
|
|
|
* furnished to do so, subject to the following conditions: |
11
|
|
|
* |
12
|
|
|
* The above copyright notice and this permission notice shall be included in |
13
|
|
|
* all copies or substantial portions of the Software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21
|
|
|
* THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
* @category HybridAuth |
24
|
|
|
* @author Andreas Heigl<[email protected]> |
25
|
|
|
* @copyright 2011-2012 php.ug |
26
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT-License |
27
|
|
|
* @version 0.0 |
28
|
|
|
* @since 06.03.2012 |
29
|
|
|
* @link http://github.com/heiglandreas/php.ug |
30
|
|
|
*/ |
31
|
|
|
namespace OrgHeiglHybridAuth; |
32
|
|
|
|
33
|
|
|
use OrgHeiglHybridAuth\Controller\IndexController; |
34
|
|
|
use OrgHeiglHybridAuth\Service\HybridAuthFactory; |
35
|
|
|
use OrgHeiglHybridAuth\Service\IndexControllerFactory; |
36
|
|
|
use OrgHeiglHybridAuth\Service\SessionFactory; |
37
|
|
|
use OrgHeiglHybridAuth\Service\UserFactory; |
38
|
|
|
use OrgHeiglHybridAuth\Service\ViewHelperFactory; |
39
|
|
|
use OrgHeiglHybridAuth\View\Helper\HybridAuth; |
40
|
|
|
use SocialConnect\Common\Http\Client\ClientInterface; |
41
|
|
|
use SocialConnect\Common\Http\Client\Guzzle; |
42
|
|
|
use SocialConnect\Provider\Session\Session; |
43
|
|
|
use SocialConnect\Provider\Session\SessionInterface; |
44
|
|
|
|
45
|
|
|
return [ |
46
|
|
|
'router' => [ |
47
|
|
|
'routes' => [ |
48
|
|
|
'hybridauth' => [ |
49
|
|
|
'type' => 'Literal', |
50
|
|
|
'options' => [ |
51
|
|
|
'route' => '/authenticate', |
52
|
|
|
'defaults' => [ |
53
|
|
|
'__NAMESPACE__' => 'OrgHeiglHybridAuth\Controller', |
54
|
|
|
'controller' => 'IndexController', |
55
|
|
|
'action' => 'login', |
56
|
|
|
], |
57
|
|
|
], |
58
|
|
|
'may_terminate' => true, |
59
|
|
|
'child_routes' => [ |
60
|
|
|
'login' => [ |
61
|
|
|
'type' => 'Segment', |
62
|
|
|
'options' => [ |
63
|
|
|
'route' => '/login/:provider[/:redirect]', |
64
|
|
|
'defaults' => [ |
65
|
|
|
'action' => 'login', |
66
|
|
|
'redirect' => 'home' |
67
|
|
|
], |
68
|
|
|
], |
69
|
|
|
], |
70
|
|
|
'logout' => [ |
71
|
|
|
'type' => 'Segment', |
72
|
|
|
'options' => [ |
73
|
|
|
'route' => '/logout[/:redirect]', |
74
|
|
|
'defaults' => [ |
75
|
|
|
'action' => 'logout', |
76
|
|
|
'redirect' => 'home' |
77
|
|
|
], |
78
|
|
|
], |
79
|
|
|
], |
80
|
|
|
'backend' => [ |
81
|
|
|
'type' => 'Segment', |
82
|
|
|
'options' => [ |
83
|
|
|
'route' => '/backend/:provider[/]', |
84
|
|
|
'defaults' => [ |
85
|
|
|
'action' => 'backend', |
86
|
|
|
'redirect' => 'home', |
87
|
|
|
], |
88
|
|
|
], |
89
|
|
|
] |
90
|
|
|
], |
91
|
|
|
], |
92
|
|
|
], |
93
|
|
|
], |
94
|
|
|
'controllers' => [ |
95
|
|
|
'factories' => [ |
96
|
|
|
IndexController::class => IndexControllerFactory::class, |
97
|
|
|
], |
98
|
|
|
], |
99
|
|
|
'service_manager' => [ |
100
|
|
|
'factories' => [ |
101
|
|
|
'OrgHeiglHybridAuthSession' => SessionFactory::class, |
102
|
|
|
'OrgHeiglHybridAuthBackend' => HybridAuthFactory::class, |
103
|
|
|
'OrgHeiglHybridAuthToken' => UserFactory::class, |
104
|
|
|
], |
105
|
|
|
'invokables' => [ |
106
|
|
|
UserWrapperFactory::class => UserWrapperFactory::class, |
107
|
|
|
ClientInterface::class => Guzzle::class, |
108
|
|
|
SessionInterface::class => Session::class, |
109
|
|
|
], |
110
|
|
|
], |
111
|
|
|
'view_helpers' => [ |
112
|
|
|
'factories' => [ |
113
|
|
|
HybridAuth::class => ViewHelperFactory::class, |
114
|
|
|
], |
115
|
|
|
'aliases' => [ |
116
|
|
|
'hybridauthinfo' => HybridAuth::class |
117
|
|
|
] |
118
|
|
|
], |
119
|
|
|
'OrgHeiglHybridAuth' => [ |
120
|
|
|
'socialAuth' => [ |
121
|
|
|
'redirectUri' => 'http://localhost:8080/authenticate/backend', |
122
|
|
|
'provider' => [ |
123
|
|
|
'twitter' => [ |
124
|
|
|
'applicationId' => '', |
125
|
|
|
'applicationSecret' => '', |
126
|
|
|
'scope' => ['email'], |
127
|
|
|
], |
128
|
|
|
'github' => [ |
129
|
|
|
'applicationId' => '', |
130
|
|
|
'applicationSecret' => '', |
131
|
|
|
'scope' => ['email'], |
132
|
|
|
], |
133
|
|
|
], |
134
|
|
|
], |
135
|
|
|
'backend' => 'Twitter', |
136
|
|
|
// 'backend' => ['Twitter' => 'twitter'], |
|
|
|
|
137
|
|
|
// 'backend' => ['Twitter' => 'twitter', 'Facebook' => 'facebook', '...'], |
138
|
|
|
'link' => '<a class="hybridauth" href="%2$s">%1$s</a>', // Will be either inserted as first parameter into item or simply returned as complete entry |
139
|
|
|
'item' => '<li%2$s>%1$s</li>', |
140
|
|
|
'itemlist' => '<ul%2$s>%1$s</ul>', |
141
|
|
|
'logincontainer' => '<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">%1$s<b class="caret"></b></a>%2$s</li>', |
142
|
|
|
'logoffcontainer' => '<li>%1$s</li>', |
143
|
|
|
'logoffstring' => 'Logout %1$s', |
144
|
|
|
'loginstring' => 'Login%1$s', |
145
|
|
|
'listAttribs' => ' class="dropdown-menu"', // Will be inserted as 2nd parameter into item |
146
|
|
|
'itemAttribs' => null, // Will be inserted as 2nd parameter into itemlist |
147
|
|
|
] |
148
|
|
|
]; |
149
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.