@@ -42,6 +42,10 @@ |
||
42 | 42 | $this->database = $database; |
43 | 43 | } |
44 | 44 | |
45 | + /** |
|
46 | + * @param string $data |
|
47 | + * @param integer $stage |
|
48 | + */ |
|
45 | 49 | public function authenticate(User $user, $data, $stage) |
46 | 50 | { |
47 | 51 | $sql = 'SELECT type FROM credential WHERE user = :user AND factor = :stage'; |
@@ -14,7 +14,6 @@ |
||
14 | 14 | use Waca\PdoDatabase; |
15 | 15 | use Waca\Security\CredentialProviders\ICredentialProvider; |
16 | 16 | use Waca\Security\CredentialProviders\PasswordCredentialProvider; |
17 | -use Waca\Security\CredentialProviders\YubikeyCredentialProvider; |
|
18 | 17 | use Waca\SiteConfiguration; |
19 | 18 | |
20 | 19 | class AuthenticationManager |
@@ -19,62 +19,62 @@ |
||
19 | 19 | |
20 | 20 | class AuthenticationManager |
21 | 21 | { |
22 | - const AUTH_OK = 1; |
|
23 | - const AUTH_FAIL = 2; |
|
24 | - const AUTH_REQUIRE_NEXT_STAGE = 3; |
|
25 | - private $typeMap = array(); |
|
26 | - /** |
|
27 | - * @var PdoDatabase |
|
28 | - */ |
|
29 | - private $database; |
|
22 | + const AUTH_OK = 1; |
|
23 | + const AUTH_FAIL = 2; |
|
24 | + const AUTH_REQUIRE_NEXT_STAGE = 3; |
|
25 | + private $typeMap = array(); |
|
26 | + /** |
|
27 | + * @var PdoDatabase |
|
28 | + */ |
|
29 | + private $database; |
|
30 | 30 | |
31 | - /** |
|
32 | - * AuthenticationManager constructor. |
|
33 | - * |
|
34 | - * @param PdoDatabase $database |
|
35 | - * @param SiteConfiguration $siteConfiguration |
|
36 | - * @param HttpHelper $httpHelper |
|
37 | - */ |
|
38 | - public function __construct(PdoDatabase $database, SiteConfiguration $siteConfiguration, HttpHelper $httpHelper) |
|
39 | - { |
|
40 | - // setup providers |
|
41 | - $this->typeMap['password'] = new PasswordCredentialProvider($database, $siteConfiguration); |
|
42 | - $this->database = $database; |
|
43 | - } |
|
31 | + /** |
|
32 | + * AuthenticationManager constructor. |
|
33 | + * |
|
34 | + * @param PdoDatabase $database |
|
35 | + * @param SiteConfiguration $siteConfiguration |
|
36 | + * @param HttpHelper $httpHelper |
|
37 | + */ |
|
38 | + public function __construct(PdoDatabase $database, SiteConfiguration $siteConfiguration, HttpHelper $httpHelper) |
|
39 | + { |
|
40 | + // setup providers |
|
41 | + $this->typeMap['password'] = new PasswordCredentialProvider($database, $siteConfiguration); |
|
42 | + $this->database = $database; |
|
43 | + } |
|
44 | 44 | |
45 | - public function authenticate(User $user, $data, $stage) |
|
46 | - { |
|
47 | - $sql = 'SELECT type FROM credential WHERE user = :user AND factor = :stage'; |
|
48 | - $statement = $this->database->prepare($sql); |
|
49 | - $statement->execute(array(':user' => $user->getId(), ':stage' => $stage)); |
|
50 | - $options = $statement->fetchAll(PDO::FETCH_COLUMN); |
|
45 | + public function authenticate(User $user, $data, $stage) |
|
46 | + { |
|
47 | + $sql = 'SELECT type FROM credential WHERE user = :user AND factor = :stage'; |
|
48 | + $statement = $this->database->prepare($sql); |
|
49 | + $statement->execute(array(':user' => $user->getId(), ':stage' => $stage)); |
|
50 | + $options = $statement->fetchAll(PDO::FETCH_COLUMN); |
|
51 | 51 | |
52 | - $sql = 'SELECT count(DISTINCT factor) FROM credential WHERE user = :user AND factor > :stage'; |
|
53 | - $statement = $this->database->prepare($sql); |
|
54 | - $statement->execute(array(':user' => $user->getId(), ':stage' => $stage)); |
|
55 | - $requiredFactors = $statement->fetchColumn(); |
|
52 | + $sql = 'SELECT count(DISTINCT factor) FROM credential WHERE user = :user AND factor > :stage'; |
|
53 | + $statement = $this->database->prepare($sql); |
|
54 | + $statement->execute(array(':user' => $user->getId(), ':stage' => $stage)); |
|
55 | + $requiredFactors = $statement->fetchColumn(); |
|
56 | 56 | |
57 | - // prep the correct OK response based on how many factors are ahead of this one |
|
58 | - $success = self::AUTH_OK; |
|
59 | - if ($requiredFactors > 0) { |
|
60 | - $success = self::AUTH_REQUIRE_NEXT_STAGE; |
|
61 | - } |
|
57 | + // prep the correct OK response based on how many factors are ahead of this one |
|
58 | + $success = self::AUTH_OK; |
|
59 | + if ($requiredFactors > 0) { |
|
60 | + $success = self::AUTH_REQUIRE_NEXT_STAGE; |
|
61 | + } |
|
62 | 62 | |
63 | - foreach ($options as $type) { |
|
64 | - if (!isset($this->typeMap[$type])) { |
|
65 | - // does this type have a credentialProvider registered? |
|
66 | - continue; |
|
67 | - } |
|
63 | + foreach ($options as $type) { |
|
64 | + if (!isset($this->typeMap[$type])) { |
|
65 | + // does this type have a credentialProvider registered? |
|
66 | + continue; |
|
67 | + } |
|
68 | 68 | |
69 | - /** @var ICredentialProvider $credentialProvider */ |
|
70 | - $credentialProvider = $this->typeMap[$type]; |
|
71 | - if ($credentialProvider->authenticate($user, $data)) { |
|
72 | - return $success; |
|
73 | - } |
|
74 | - } |
|
69 | + /** @var ICredentialProvider $credentialProvider */ |
|
70 | + $credentialProvider = $this->typeMap[$type]; |
|
71 | + if ($credentialProvider->authenticate($user, $data)) { |
|
72 | + return $success; |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - // We've iterated over all the available providers for this stage. |
|
77 | - // They all hate you. |
|
78 | - return self::AUTH_FAIL; |
|
79 | - } |
|
76 | + // We've iterated over all the available providers for this stage. |
|
77 | + // They all hate you. |
|
78 | + return self::AUTH_FAIL; |
|
79 | + } |
|
80 | 80 | } |
81 | 81 | \ No newline at end of file |
@@ -16,10 +16,6 @@ discard block |
||
16 | 16 | use Waca\Pages\PageJobQueue; |
17 | 17 | use Waca\Pages\PageLog; |
18 | 18 | use Waca\Pages\PageMain; |
19 | -use Waca\Pages\RequestAction\PageCreateRequest; |
|
20 | -use Waca\Pages\UserAuth\PageChangePassword; |
|
21 | -use Waca\Pages\UserAuth\PageOAuth; |
|
22 | -use Waca\Pages\UserAuth\PagePreferences; |
|
23 | 19 | use Waca\Pages\PageSearch; |
24 | 20 | use Waca\Pages\PageSiteNotice; |
25 | 21 | use Waca\Pages\PageTeam; |
@@ -29,6 +25,7 @@ discard block |
||
29 | 25 | use Waca\Pages\RequestAction\PageBreakReservation; |
30 | 26 | use Waca\Pages\RequestAction\PageCloseRequest; |
31 | 27 | use Waca\Pages\RequestAction\PageComment; |
28 | +use Waca\Pages\RequestAction\PageCreateRequest; |
|
32 | 29 | use Waca\Pages\RequestAction\PageCustomClose; |
33 | 30 | use Waca\Pages\RequestAction\PageDeferRequest; |
34 | 31 | use Waca\Pages\RequestAction\PageDropRequest; |
@@ -42,6 +39,9 @@ discard block |
||
42 | 39 | use Waca\Pages\Statistics\StatsTemplateStats; |
43 | 40 | use Waca\Pages\Statistics\StatsTopCreators; |
44 | 41 | use Waca\Pages\Statistics\StatsUsers; |
42 | +use Waca\Pages\UserAuth\PageChangePassword; |
|
43 | +use Waca\Pages\UserAuth\PageOAuth; |
|
44 | +use Waca\Pages\UserAuth\PagePreferences; |
|
45 | 45 | |
46 | 46 | class RoleConfiguration |
47 | 47 | { |
@@ -45,364 +45,364 @@ |
||
45 | 45 | |
46 | 46 | class RoleConfiguration |
47 | 47 | { |
48 | - const ACCESS_ALLOW = 1; |
|
49 | - const ACCESS_DENY = -1; |
|
50 | - const ACCESS_DEFAULT = 0; |
|
51 | - const MAIN = 'main'; |
|
52 | - const ALL = '*'; |
|
53 | - /** |
|
54 | - * A map of roles to rights |
|
55 | - * |
|
56 | - * For example: |
|
57 | - * |
|
58 | - * array( |
|
59 | - * 'myrole' => array( |
|
60 | - * PageMyPage::class => array( |
|
61 | - * 'edit' => self::ACCESS_ALLOW, |
|
62 | - * 'create' => self::ACCESS_DENY, |
|
63 | - * ) |
|
64 | - * ) |
|
65 | - * ) |
|
66 | - * |
|
67 | - * Note that DENY takes precedence over everything else when roles are combined, followed by ALLOW, followed by |
|
68 | - * DEFAULT. Thus, if you have the following ([A]llow, [D]eny, [-] (default)) grants in different roles, this should |
|
69 | - * be the expected result: |
|
70 | - * |
|
71 | - * - (-,-,-) = - (default because nothing to explicitly say allowed or denied equates to a denial) |
|
72 | - * - (A,-,-) = A |
|
73 | - * - (D,-,-) = D |
|
74 | - * - (A,D,-) = D (deny takes precedence over allow) |
|
75 | - * - (A,A,A) = A (repetition has no effect) |
|
76 | - * |
|
77 | - * The public role is special, and is applied to all users automatically. Avoid using deny on this role. |
|
78 | - * |
|
79 | - * @var array |
|
80 | - */ |
|
81 | - private $roleConfig = array( |
|
82 | - 'public' => array( |
|
83 | - /* |
|
48 | + const ACCESS_ALLOW = 1; |
|
49 | + const ACCESS_DENY = -1; |
|
50 | + const ACCESS_DEFAULT = 0; |
|
51 | + const MAIN = 'main'; |
|
52 | + const ALL = '*'; |
|
53 | + /** |
|
54 | + * A map of roles to rights |
|
55 | + * |
|
56 | + * For example: |
|
57 | + * |
|
58 | + * array( |
|
59 | + * 'myrole' => array( |
|
60 | + * PageMyPage::class => array( |
|
61 | + * 'edit' => self::ACCESS_ALLOW, |
|
62 | + * 'create' => self::ACCESS_DENY, |
|
63 | + * ) |
|
64 | + * ) |
|
65 | + * ) |
|
66 | + * |
|
67 | + * Note that DENY takes precedence over everything else when roles are combined, followed by ALLOW, followed by |
|
68 | + * DEFAULT. Thus, if you have the following ([A]llow, [D]eny, [-] (default)) grants in different roles, this should |
|
69 | + * be the expected result: |
|
70 | + * |
|
71 | + * - (-,-,-) = - (default because nothing to explicitly say allowed or denied equates to a denial) |
|
72 | + * - (A,-,-) = A |
|
73 | + * - (D,-,-) = D |
|
74 | + * - (A,D,-) = D (deny takes precedence over allow) |
|
75 | + * - (A,A,A) = A (repetition has no effect) |
|
76 | + * |
|
77 | + * The public role is special, and is applied to all users automatically. Avoid using deny on this role. |
|
78 | + * |
|
79 | + * @var array |
|
80 | + */ |
|
81 | + private $roleConfig = array( |
|
82 | + 'public' => array( |
|
83 | + /* |
|
84 | 84 | * THIS ROLE IS GRANTED TO ALL LOGGED *OUT* USERS IMPLICITLY. |
85 | 85 | * |
86 | 86 | * USERS IN THIS ROLE DO NOT HAVE TO BE IDENTIFIED TO GET THE RIGHTS CONFERRED HERE. |
87 | 87 | * DO NOT ADD ANY SECURITY-SENSITIVE RIGHTS HERE. |
88 | 88 | */ |
89 | - '_childRoles' => array( |
|
90 | - 'publicStats', |
|
91 | - ), |
|
92 | - PageTeam::class => array( |
|
93 | - self::MAIN => self::ACCESS_ALLOW, |
|
94 | - ), |
|
95 | - ), |
|
96 | - 'loggedIn' => array( |
|
97 | - /* |
|
89 | + '_childRoles' => array( |
|
90 | + 'publicStats', |
|
91 | + ), |
|
92 | + PageTeam::class => array( |
|
93 | + self::MAIN => self::ACCESS_ALLOW, |
|
94 | + ), |
|
95 | + ), |
|
96 | + 'loggedIn' => array( |
|
97 | + /* |
|
98 | 98 | * THIS ROLE IS GRANTED TO ALL LOGGED IN USERS IMPLICITLY. |
99 | 99 | * |
100 | 100 | * USERS IN THIS ROLE DO NOT HAVE TO BE IDENTIFIED TO GET THE RIGHTS CONFERRED HERE. |
101 | 101 | * DO NOT ADD ANY SECURITY-SENSITIVE RIGHTS HERE. |
102 | 102 | */ |
103 | - '_childRoles' => array( |
|
104 | - 'public', |
|
105 | - ), |
|
106 | - PagePreferences::class => array( |
|
107 | - self::MAIN => self::ACCESS_ALLOW, |
|
108 | - ), |
|
109 | - PageChangePassword::class => array( |
|
110 | - self::MAIN => self::ACCESS_ALLOW, |
|
111 | - ), |
|
112 | - PageOAuth::class => array( |
|
113 | - 'attach' => self::ACCESS_ALLOW, |
|
114 | - 'detach' => self::ACCESS_ALLOW, |
|
115 | - ), |
|
116 | - ), |
|
117 | - 'user' => array( |
|
118 | - '_description' => 'A standard tool user.', |
|
119 | - '_editableBy' => array('admin', 'toolRoot'), |
|
120 | - '_childRoles' => array( |
|
121 | - 'internalStats', |
|
122 | - ), |
|
123 | - PageMain::class => array( |
|
124 | - self::MAIN => self::ACCESS_ALLOW, |
|
125 | - ), |
|
126 | - PageBan::class => array( |
|
127 | - self::MAIN => self::ACCESS_ALLOW, |
|
128 | - ), |
|
129 | - PageEditComment::class => array( |
|
130 | - self::MAIN => self::ACCESS_ALLOW, |
|
131 | - ), |
|
132 | - PageEmailManagement::class => array( |
|
133 | - self::MAIN => self::ACCESS_ALLOW, |
|
134 | - 'view' => self::ACCESS_ALLOW, |
|
135 | - ), |
|
136 | - PageExpandedRequestList::class => array( |
|
137 | - self::MAIN => self::ACCESS_ALLOW, |
|
138 | - ), |
|
139 | - PageLog::class => array( |
|
140 | - self::MAIN => self::ACCESS_ALLOW, |
|
141 | - ), |
|
142 | - PageSearch::class => array( |
|
143 | - self::MAIN => self::ACCESS_ALLOW, |
|
144 | - ), |
|
145 | - PageWelcomeTemplateManagement::class => array( |
|
146 | - self::MAIN => self::ACCESS_ALLOW, |
|
147 | - 'select' => self::ACCESS_ALLOW, |
|
148 | - 'view' => self::ACCESS_ALLOW, |
|
149 | - ), |
|
150 | - PageViewRequest::class => array( |
|
151 | - self::MAIN => self::ACCESS_ALLOW, |
|
152 | - 'seeAllRequests' => self::ACCESS_ALLOW, |
|
153 | - ), |
|
154 | - 'RequestData' => array( |
|
155 | - 'seePrivateDataWhenReserved' => self::ACCESS_ALLOW, |
|
156 | - 'seePrivateDataWithHash' => self::ACCESS_ALLOW, |
|
157 | - ), |
|
158 | - PageCustomClose::class => array( |
|
159 | - self::MAIN => self::ACCESS_ALLOW, |
|
160 | - ), |
|
161 | - PageComment::class => array( |
|
162 | - self::MAIN => self::ACCESS_ALLOW, |
|
163 | - ), |
|
164 | - PageCloseRequest::class => array( |
|
165 | - self::MAIN => self::ACCESS_ALLOW, |
|
166 | - ), |
|
167 | - PageCreateRequest::class => array( |
|
168 | - self::MAIN => self::ACCESS_ALLOW, |
|
169 | - ), |
|
170 | - PageDeferRequest::class => array( |
|
171 | - self::MAIN => self::ACCESS_ALLOW, |
|
172 | - ), |
|
173 | - PageDropRequest::class => array( |
|
174 | - self::MAIN => self::ACCESS_ALLOW, |
|
175 | - ), |
|
176 | - PageReservation::class => array( |
|
177 | - self::MAIN => self::ACCESS_ALLOW, |
|
178 | - ), |
|
179 | - PageSendToUser::class => array( |
|
180 | - self::MAIN => self::ACCESS_ALLOW, |
|
181 | - ), |
|
182 | - PageBreakReservation::class => array( |
|
183 | - self::MAIN => self::ACCESS_ALLOW, |
|
184 | - ), |
|
185 | - PageJobQueue::class => array( |
|
186 | - self::MAIN => self::ACCESS_ALLOW, |
|
187 | - 'view' => self::ACCESS_ALLOW, |
|
188 | - 'all' => self::ACCESS_ALLOW, |
|
189 | - ), |
|
190 | - 'RequestCreation' => array( |
|
191 | - User::CREATION_MANUAL => self::ACCESS_ALLOW, |
|
192 | - User::CREATION_OAUTH => self::ACCESS_ALLOW, |
|
193 | - ), |
|
194 | - ), |
|
195 | - 'admin' => array( |
|
196 | - '_description' => 'A tool administrator.', |
|
197 | - '_editableBy' => array('admin', 'toolRoot'), |
|
198 | - '_childRoles' => array( |
|
199 | - 'user', |
|
200 | - 'requestAdminTools', |
|
201 | - ), |
|
202 | - PageEmailManagement::class => array( |
|
203 | - 'edit' => self::ACCESS_ALLOW, |
|
204 | - 'create' => self::ACCESS_ALLOW, |
|
205 | - ), |
|
206 | - PageSiteNotice::class => array( |
|
207 | - self::MAIN => self::ACCESS_ALLOW, |
|
208 | - ), |
|
209 | - PageUserManagement::class => array( |
|
210 | - self::MAIN => self::ACCESS_ALLOW, |
|
211 | - 'approve' => self::ACCESS_ALLOW, |
|
212 | - 'decline' => self::ACCESS_ALLOW, |
|
213 | - 'rename' => self::ACCESS_ALLOW, |
|
214 | - 'editUser' => self::ACCESS_ALLOW, |
|
215 | - 'suspend' => self::ACCESS_ALLOW, |
|
216 | - 'editRoles' => self::ACCESS_ALLOW, |
|
217 | - ), |
|
218 | - PageWelcomeTemplateManagement::class => array( |
|
219 | - 'edit' => self::ACCESS_ALLOW, |
|
220 | - 'delete' => self::ACCESS_ALLOW, |
|
221 | - 'add' => self::ACCESS_ALLOW, |
|
222 | - ), |
|
223 | - PageJobQueue::class => array( |
|
224 | - 'acknowledge' => self::ACCESS_ALLOW, |
|
225 | - 'requeue' => self::ACCESS_ALLOW, |
|
226 | - ), |
|
227 | - ), |
|
228 | - 'checkuser' => array( |
|
229 | - '_description' => 'A user with CheckUser access', |
|
230 | - '_editableBy' => array('checkuser', 'toolRoot'), |
|
231 | - '_childRoles' => array( |
|
232 | - 'user', |
|
233 | - 'requestAdminTools', |
|
234 | - ), |
|
235 | - PageUserManagement::class => array( |
|
236 | - self::MAIN => self::ACCESS_ALLOW, |
|
237 | - 'suspend' => self::ACCESS_ALLOW, |
|
238 | - 'editRoles' => self::ACCESS_ALLOW, |
|
239 | - ), |
|
240 | - 'RequestData' => array( |
|
241 | - 'seeUserAgentData' => self::ACCESS_ALLOW, |
|
242 | - ), |
|
243 | - ), |
|
244 | - 'toolRoot' => array( |
|
245 | - '_description' => 'A user with shell access to the servers running the tool', |
|
246 | - '_editableBy' => array('toolRoot'), |
|
247 | - '_childRoles' => array( |
|
248 | - 'admin', |
|
249 | - 'checkuser', |
|
250 | - ), |
|
251 | - ), |
|
252 | - 'botCreation' => array( |
|
253 | - '_description' => 'A user allowed to use the bot to perform account creations', |
|
254 | - '_editableBy' => array('admin', 'toolRoot'), |
|
255 | - '_childRoles' => array(), |
|
256 | - 'RequestCreation' => array( |
|
257 | - User::CREATION_BOT => self::ACCESS_ALLOW, |
|
258 | - ), |
|
259 | - ), |
|
103 | + '_childRoles' => array( |
|
104 | + 'public', |
|
105 | + ), |
|
106 | + PagePreferences::class => array( |
|
107 | + self::MAIN => self::ACCESS_ALLOW, |
|
108 | + ), |
|
109 | + PageChangePassword::class => array( |
|
110 | + self::MAIN => self::ACCESS_ALLOW, |
|
111 | + ), |
|
112 | + PageOAuth::class => array( |
|
113 | + 'attach' => self::ACCESS_ALLOW, |
|
114 | + 'detach' => self::ACCESS_ALLOW, |
|
115 | + ), |
|
116 | + ), |
|
117 | + 'user' => array( |
|
118 | + '_description' => 'A standard tool user.', |
|
119 | + '_editableBy' => array('admin', 'toolRoot'), |
|
120 | + '_childRoles' => array( |
|
121 | + 'internalStats', |
|
122 | + ), |
|
123 | + PageMain::class => array( |
|
124 | + self::MAIN => self::ACCESS_ALLOW, |
|
125 | + ), |
|
126 | + PageBan::class => array( |
|
127 | + self::MAIN => self::ACCESS_ALLOW, |
|
128 | + ), |
|
129 | + PageEditComment::class => array( |
|
130 | + self::MAIN => self::ACCESS_ALLOW, |
|
131 | + ), |
|
132 | + PageEmailManagement::class => array( |
|
133 | + self::MAIN => self::ACCESS_ALLOW, |
|
134 | + 'view' => self::ACCESS_ALLOW, |
|
135 | + ), |
|
136 | + PageExpandedRequestList::class => array( |
|
137 | + self::MAIN => self::ACCESS_ALLOW, |
|
138 | + ), |
|
139 | + PageLog::class => array( |
|
140 | + self::MAIN => self::ACCESS_ALLOW, |
|
141 | + ), |
|
142 | + PageSearch::class => array( |
|
143 | + self::MAIN => self::ACCESS_ALLOW, |
|
144 | + ), |
|
145 | + PageWelcomeTemplateManagement::class => array( |
|
146 | + self::MAIN => self::ACCESS_ALLOW, |
|
147 | + 'select' => self::ACCESS_ALLOW, |
|
148 | + 'view' => self::ACCESS_ALLOW, |
|
149 | + ), |
|
150 | + PageViewRequest::class => array( |
|
151 | + self::MAIN => self::ACCESS_ALLOW, |
|
152 | + 'seeAllRequests' => self::ACCESS_ALLOW, |
|
153 | + ), |
|
154 | + 'RequestData' => array( |
|
155 | + 'seePrivateDataWhenReserved' => self::ACCESS_ALLOW, |
|
156 | + 'seePrivateDataWithHash' => self::ACCESS_ALLOW, |
|
157 | + ), |
|
158 | + PageCustomClose::class => array( |
|
159 | + self::MAIN => self::ACCESS_ALLOW, |
|
160 | + ), |
|
161 | + PageComment::class => array( |
|
162 | + self::MAIN => self::ACCESS_ALLOW, |
|
163 | + ), |
|
164 | + PageCloseRequest::class => array( |
|
165 | + self::MAIN => self::ACCESS_ALLOW, |
|
166 | + ), |
|
167 | + PageCreateRequest::class => array( |
|
168 | + self::MAIN => self::ACCESS_ALLOW, |
|
169 | + ), |
|
170 | + PageDeferRequest::class => array( |
|
171 | + self::MAIN => self::ACCESS_ALLOW, |
|
172 | + ), |
|
173 | + PageDropRequest::class => array( |
|
174 | + self::MAIN => self::ACCESS_ALLOW, |
|
175 | + ), |
|
176 | + PageReservation::class => array( |
|
177 | + self::MAIN => self::ACCESS_ALLOW, |
|
178 | + ), |
|
179 | + PageSendToUser::class => array( |
|
180 | + self::MAIN => self::ACCESS_ALLOW, |
|
181 | + ), |
|
182 | + PageBreakReservation::class => array( |
|
183 | + self::MAIN => self::ACCESS_ALLOW, |
|
184 | + ), |
|
185 | + PageJobQueue::class => array( |
|
186 | + self::MAIN => self::ACCESS_ALLOW, |
|
187 | + 'view' => self::ACCESS_ALLOW, |
|
188 | + 'all' => self::ACCESS_ALLOW, |
|
189 | + ), |
|
190 | + 'RequestCreation' => array( |
|
191 | + User::CREATION_MANUAL => self::ACCESS_ALLOW, |
|
192 | + User::CREATION_OAUTH => self::ACCESS_ALLOW, |
|
193 | + ), |
|
194 | + ), |
|
195 | + 'admin' => array( |
|
196 | + '_description' => 'A tool administrator.', |
|
197 | + '_editableBy' => array('admin', 'toolRoot'), |
|
198 | + '_childRoles' => array( |
|
199 | + 'user', |
|
200 | + 'requestAdminTools', |
|
201 | + ), |
|
202 | + PageEmailManagement::class => array( |
|
203 | + 'edit' => self::ACCESS_ALLOW, |
|
204 | + 'create' => self::ACCESS_ALLOW, |
|
205 | + ), |
|
206 | + PageSiteNotice::class => array( |
|
207 | + self::MAIN => self::ACCESS_ALLOW, |
|
208 | + ), |
|
209 | + PageUserManagement::class => array( |
|
210 | + self::MAIN => self::ACCESS_ALLOW, |
|
211 | + 'approve' => self::ACCESS_ALLOW, |
|
212 | + 'decline' => self::ACCESS_ALLOW, |
|
213 | + 'rename' => self::ACCESS_ALLOW, |
|
214 | + 'editUser' => self::ACCESS_ALLOW, |
|
215 | + 'suspend' => self::ACCESS_ALLOW, |
|
216 | + 'editRoles' => self::ACCESS_ALLOW, |
|
217 | + ), |
|
218 | + PageWelcomeTemplateManagement::class => array( |
|
219 | + 'edit' => self::ACCESS_ALLOW, |
|
220 | + 'delete' => self::ACCESS_ALLOW, |
|
221 | + 'add' => self::ACCESS_ALLOW, |
|
222 | + ), |
|
223 | + PageJobQueue::class => array( |
|
224 | + 'acknowledge' => self::ACCESS_ALLOW, |
|
225 | + 'requeue' => self::ACCESS_ALLOW, |
|
226 | + ), |
|
227 | + ), |
|
228 | + 'checkuser' => array( |
|
229 | + '_description' => 'A user with CheckUser access', |
|
230 | + '_editableBy' => array('checkuser', 'toolRoot'), |
|
231 | + '_childRoles' => array( |
|
232 | + 'user', |
|
233 | + 'requestAdminTools', |
|
234 | + ), |
|
235 | + PageUserManagement::class => array( |
|
236 | + self::MAIN => self::ACCESS_ALLOW, |
|
237 | + 'suspend' => self::ACCESS_ALLOW, |
|
238 | + 'editRoles' => self::ACCESS_ALLOW, |
|
239 | + ), |
|
240 | + 'RequestData' => array( |
|
241 | + 'seeUserAgentData' => self::ACCESS_ALLOW, |
|
242 | + ), |
|
243 | + ), |
|
244 | + 'toolRoot' => array( |
|
245 | + '_description' => 'A user with shell access to the servers running the tool', |
|
246 | + '_editableBy' => array('toolRoot'), |
|
247 | + '_childRoles' => array( |
|
248 | + 'admin', |
|
249 | + 'checkuser', |
|
250 | + ), |
|
251 | + ), |
|
252 | + 'botCreation' => array( |
|
253 | + '_description' => 'A user allowed to use the bot to perform account creations', |
|
254 | + '_editableBy' => array('admin', 'toolRoot'), |
|
255 | + '_childRoles' => array(), |
|
256 | + 'RequestCreation' => array( |
|
257 | + User::CREATION_BOT => self::ACCESS_ALLOW, |
|
258 | + ), |
|
259 | + ), |
|
260 | 260 | |
261 | - // Child roles go below this point |
|
262 | - 'publicStats' => array( |
|
263 | - '_hidden' => true, |
|
264 | - StatsUsers::class => array( |
|
265 | - self::MAIN => self::ACCESS_ALLOW, |
|
266 | - 'detail' => self::ACCESS_ALLOW, |
|
267 | - ), |
|
268 | - StatsTopCreators::class => array( |
|
269 | - self::MAIN => self::ACCESS_ALLOW, |
|
270 | - ), |
|
271 | - ), |
|
272 | - 'internalStats' => array( |
|
273 | - '_hidden' => true, |
|
274 | - StatsMain::class => array( |
|
275 | - self::MAIN => self::ACCESS_ALLOW, |
|
276 | - ), |
|
277 | - StatsFastCloses::class => array( |
|
278 | - self::MAIN => self::ACCESS_ALLOW, |
|
279 | - ), |
|
280 | - StatsInactiveUsers::class => array( |
|
281 | - self::MAIN => self::ACCESS_ALLOW, |
|
282 | - ), |
|
283 | - StatsMonthlyStats::class => array( |
|
284 | - self::MAIN => self::ACCESS_ALLOW, |
|
285 | - ), |
|
286 | - StatsReservedRequests::class => array( |
|
287 | - self::MAIN => self::ACCESS_ALLOW, |
|
288 | - ), |
|
289 | - StatsTemplateStats::class => array( |
|
290 | - self::MAIN => self::ACCESS_ALLOW, |
|
291 | - ), |
|
292 | - ), |
|
293 | - 'requestAdminTools' => array( |
|
294 | - '_hidden' => true, |
|
295 | - PageBan::class => array( |
|
296 | - self::MAIN => self::ACCESS_ALLOW, |
|
297 | - 'set' => self::ACCESS_ALLOW, |
|
298 | - 'remove' => self::ACCESS_ALLOW, |
|
299 | - ), |
|
300 | - PageEditComment::class => array( |
|
301 | - 'editOthers' => self::ACCESS_ALLOW, |
|
302 | - ), |
|
303 | - PageBreakReservation::class => array( |
|
304 | - 'force' => self::ACCESS_ALLOW, |
|
305 | - ), |
|
306 | - PageCustomClose::class => array( |
|
307 | - 'skipCcMailingList' => self::ACCESS_ALLOW, |
|
308 | - ), |
|
309 | - 'RequestData' => array( |
|
310 | - 'reopenOldRequest' => self::ACCESS_ALLOW, |
|
311 | - 'alwaysSeePrivateData' => self::ACCESS_ALLOW, |
|
312 | - 'alwaysSeeHash' => self::ACCESS_ALLOW, |
|
313 | - 'seeRestrictedComments' => self::ACCESS_ALLOW, |
|
314 | - ), |
|
315 | - ), |
|
316 | - ); |
|
317 | - /** @var array |
|
318 | - * List of roles which are *exempt* from the identification requirements |
|
319 | - * |
|
320 | - * Think twice about adding roles to this list. |
|
321 | - * |
|
322 | - * @category Security-Critical |
|
323 | - */ |
|
324 | - private $identificationExempt = array('public', 'loggedIn'); |
|
261 | + // Child roles go below this point |
|
262 | + 'publicStats' => array( |
|
263 | + '_hidden' => true, |
|
264 | + StatsUsers::class => array( |
|
265 | + self::MAIN => self::ACCESS_ALLOW, |
|
266 | + 'detail' => self::ACCESS_ALLOW, |
|
267 | + ), |
|
268 | + StatsTopCreators::class => array( |
|
269 | + self::MAIN => self::ACCESS_ALLOW, |
|
270 | + ), |
|
271 | + ), |
|
272 | + 'internalStats' => array( |
|
273 | + '_hidden' => true, |
|
274 | + StatsMain::class => array( |
|
275 | + self::MAIN => self::ACCESS_ALLOW, |
|
276 | + ), |
|
277 | + StatsFastCloses::class => array( |
|
278 | + self::MAIN => self::ACCESS_ALLOW, |
|
279 | + ), |
|
280 | + StatsInactiveUsers::class => array( |
|
281 | + self::MAIN => self::ACCESS_ALLOW, |
|
282 | + ), |
|
283 | + StatsMonthlyStats::class => array( |
|
284 | + self::MAIN => self::ACCESS_ALLOW, |
|
285 | + ), |
|
286 | + StatsReservedRequests::class => array( |
|
287 | + self::MAIN => self::ACCESS_ALLOW, |
|
288 | + ), |
|
289 | + StatsTemplateStats::class => array( |
|
290 | + self::MAIN => self::ACCESS_ALLOW, |
|
291 | + ), |
|
292 | + ), |
|
293 | + 'requestAdminTools' => array( |
|
294 | + '_hidden' => true, |
|
295 | + PageBan::class => array( |
|
296 | + self::MAIN => self::ACCESS_ALLOW, |
|
297 | + 'set' => self::ACCESS_ALLOW, |
|
298 | + 'remove' => self::ACCESS_ALLOW, |
|
299 | + ), |
|
300 | + PageEditComment::class => array( |
|
301 | + 'editOthers' => self::ACCESS_ALLOW, |
|
302 | + ), |
|
303 | + PageBreakReservation::class => array( |
|
304 | + 'force' => self::ACCESS_ALLOW, |
|
305 | + ), |
|
306 | + PageCustomClose::class => array( |
|
307 | + 'skipCcMailingList' => self::ACCESS_ALLOW, |
|
308 | + ), |
|
309 | + 'RequestData' => array( |
|
310 | + 'reopenOldRequest' => self::ACCESS_ALLOW, |
|
311 | + 'alwaysSeePrivateData' => self::ACCESS_ALLOW, |
|
312 | + 'alwaysSeeHash' => self::ACCESS_ALLOW, |
|
313 | + 'seeRestrictedComments' => self::ACCESS_ALLOW, |
|
314 | + ), |
|
315 | + ), |
|
316 | + ); |
|
317 | + /** @var array |
|
318 | + * List of roles which are *exempt* from the identification requirements |
|
319 | + * |
|
320 | + * Think twice about adding roles to this list. |
|
321 | + * |
|
322 | + * @category Security-Critical |
|
323 | + */ |
|
324 | + private $identificationExempt = array('public', 'loggedIn'); |
|
325 | 325 | |
326 | - /** |
|
327 | - * RoleConfiguration constructor. |
|
328 | - * |
|
329 | - * @param array $roleConfig Set to non-null to override the default configuration. |
|
330 | - * @param array $identificationExempt Set to non-null to override the default configuration. |
|
331 | - */ |
|
332 | - public function __construct(array $roleConfig = null, array $identificationExempt = null) |
|
333 | - { |
|
334 | - if ($roleConfig !== null) { |
|
335 | - $this->roleConfig = $roleConfig; |
|
336 | - } |
|
326 | + /** |
|
327 | + * RoleConfiguration constructor. |
|
328 | + * |
|
329 | + * @param array $roleConfig Set to non-null to override the default configuration. |
|
330 | + * @param array $identificationExempt Set to non-null to override the default configuration. |
|
331 | + */ |
|
332 | + public function __construct(array $roleConfig = null, array $identificationExempt = null) |
|
333 | + { |
|
334 | + if ($roleConfig !== null) { |
|
335 | + $this->roleConfig = $roleConfig; |
|
336 | + } |
|
337 | 337 | |
338 | - if ($identificationExempt !== null) { |
|
339 | - $this->identificationExempt = $identificationExempt; |
|
340 | - } |
|
341 | - } |
|
338 | + if ($identificationExempt !== null) { |
|
339 | + $this->identificationExempt = $identificationExempt; |
|
340 | + } |
|
341 | + } |
|
342 | 342 | |
343 | - /** |
|
344 | - * @param array $roles The roles to check |
|
345 | - * |
|
346 | - * @return array |
|
347 | - */ |
|
348 | - public function getApplicableRoles(array $roles) |
|
349 | - { |
|
350 | - $available = array(); |
|
343 | + /** |
|
344 | + * @param array $roles The roles to check |
|
345 | + * |
|
346 | + * @return array |
|
347 | + */ |
|
348 | + public function getApplicableRoles(array $roles) |
|
349 | + { |
|
350 | + $available = array(); |
|
351 | 351 | |
352 | - foreach ($roles as $role) { |
|
353 | - if (!isset($this->roleConfig[$role])) { |
|
354 | - // wat |
|
355 | - continue; |
|
356 | - } |
|
352 | + foreach ($roles as $role) { |
|
353 | + if (!isset($this->roleConfig[$role])) { |
|
354 | + // wat |
|
355 | + continue; |
|
356 | + } |
|
357 | 357 | |
358 | - $available[$role] = $this->roleConfig[$role]; |
|
358 | + $available[$role] = $this->roleConfig[$role]; |
|
359 | 359 | |
360 | - if (isset($available[$role]['_childRoles'])) { |
|
361 | - $childRoles = self::getApplicableRoles($available[$role]['_childRoles']); |
|
362 | - $available = array_merge($available, $childRoles); |
|
360 | + if (isset($available[$role]['_childRoles'])) { |
|
361 | + $childRoles = self::getApplicableRoles($available[$role]['_childRoles']); |
|
362 | + $available = array_merge($available, $childRoles); |
|
363 | 363 | |
364 | - unset($available[$role]['_childRoles']); |
|
365 | - } |
|
364 | + unset($available[$role]['_childRoles']); |
|
365 | + } |
|
366 | 366 | |
367 | - foreach (array('_hidden', '_editableBy', '_description') as $item) { |
|
368 | - if (isset($available[$role][$item])) { |
|
369 | - unset($available[$role][$item]); |
|
370 | - } |
|
371 | - } |
|
372 | - } |
|
367 | + foreach (array('_hidden', '_editableBy', '_description') as $item) { |
|
368 | + if (isset($available[$role][$item])) { |
|
369 | + unset($available[$role][$item]); |
|
370 | + } |
|
371 | + } |
|
372 | + } |
|
373 | 373 | |
374 | - return $available; |
|
375 | - } |
|
374 | + return $available; |
|
375 | + } |
|
376 | 376 | |
377 | - public function getAvailableRoles() |
|
378 | - { |
|
379 | - $possible = array_diff(array_keys($this->roleConfig), array('public', 'loggedIn')); |
|
377 | + public function getAvailableRoles() |
|
378 | + { |
|
379 | + $possible = array_diff(array_keys($this->roleConfig), array('public', 'loggedIn')); |
|
380 | 380 | |
381 | - $actual = array(); |
|
381 | + $actual = array(); |
|
382 | 382 | |
383 | - foreach ($possible as $role) { |
|
384 | - if (!isset($this->roleConfig[$role]['_hidden'])) { |
|
385 | - $actual[$role] = array( |
|
386 | - 'description' => $this->roleConfig[$role]['_description'], |
|
387 | - 'editableBy' => $this->roleConfig[$role]['_editableBy'], |
|
388 | - ); |
|
389 | - } |
|
390 | - } |
|
383 | + foreach ($possible as $role) { |
|
384 | + if (!isset($this->roleConfig[$role]['_hidden'])) { |
|
385 | + $actual[$role] = array( |
|
386 | + 'description' => $this->roleConfig[$role]['_description'], |
|
387 | + 'editableBy' => $this->roleConfig[$role]['_editableBy'], |
|
388 | + ); |
|
389 | + } |
|
390 | + } |
|
391 | 391 | |
392 | - return $actual; |
|
393 | - } |
|
392 | + return $actual; |
|
393 | + } |
|
394 | 394 | |
395 | - /** |
|
396 | - * @param string $role |
|
397 | - * |
|
398 | - * @return bool |
|
399 | - */ |
|
400 | - public function roleNeedsIdentification($role) |
|
401 | - { |
|
402 | - if (in_array($role, $this->identificationExempt)) { |
|
403 | - return false; |
|
404 | - } |
|
395 | + /** |
|
396 | + * @param string $role |
|
397 | + * |
|
398 | + * @return bool |
|
399 | + */ |
|
400 | + public function roleNeedsIdentification($role) |
|
401 | + { |
|
402 | + if (in_array($role, $this->identificationExempt)) { |
|
403 | + return false; |
|
404 | + } |
|
405 | 405 | |
406 | - return true; |
|
407 | - } |
|
406 | + return true; |
|
407 | + } |
|
408 | 408 | } |
@@ -12,20 +12,20 @@ |
||
12 | 12 | |
13 | 13 | interface ICredentialProvider |
14 | 14 | { |
15 | - /** |
|
16 | - * Validates a user-provided credential |
|
17 | - * |
|
18 | - * @param User $user The user to test the authentication against |
|
19 | - * @param string $data The raw credential data to be validated |
|
20 | - * |
|
21 | - * @return bool |
|
22 | - */ |
|
23 | - public function authenticate(User $user, $data); |
|
15 | + /** |
|
16 | + * Validates a user-provided credential |
|
17 | + * |
|
18 | + * @param User $user The user to test the authentication against |
|
19 | + * @param string $data The raw credential data to be validated |
|
20 | + * |
|
21 | + * @return bool |
|
22 | + */ |
|
23 | + public function authenticate(User $user, $data); |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param User $user The user the credential belongs to |
|
27 | - * @param int $factor The factor this credential provides |
|
28 | - * @param string $data |
|
29 | - */ |
|
30 | - public function setCredential(User $user, $factor, $data); |
|
25 | + /** |
|
26 | + * @param User $user The user the credential belongs to |
|
27 | + * @param int $factor The factor this credential provides |
|
28 | + * @param string $data |
|
29 | + */ |
|
30 | + public function setCredential(User $user, $factor, $data); |
|
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -14,50 +14,50 @@ |
||
14 | 14 | |
15 | 15 | class PasswordCredentialProvider extends CredentialProviderBase |
16 | 16 | { |
17 | - const PASSWORD_COST = 10; |
|
18 | - |
|
19 | - public function __construct(PdoDatabase $database, SiteConfiguration $configuration) |
|
20 | - { |
|
21 | - parent::__construct($database, $configuration, 'password'); |
|
22 | - } |
|
23 | - |
|
24 | - public function authenticate(User $user, $data) |
|
25 | - { |
|
26 | - $storedData = $this->getCredentialData($user->getId()); |
|
27 | - if($storedData === null) |
|
28 | - { |
|
29 | - // No available credential matching these parameters |
|
30 | - return false; |
|
31 | - } |
|
32 | - |
|
33 | - if($storedData->getVersion() !== 2) { |
|
34 | - // Non-2 versions are not supported. |
|
35 | - return false; |
|
36 | - } |
|
37 | - |
|
38 | - if(password_verify($data, $storedData->getData())) { |
|
39 | - if(password_needs_rehash($storedData->getData(), PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))){ |
|
40 | - $this->setCredential($user, $storedData->getFactor(), $data); |
|
41 | - } |
|
42 | - |
|
43 | - return true; |
|
44 | - } |
|
45 | - |
|
46 | - return false; |
|
47 | - } |
|
48 | - |
|
49 | - public function setCredential(User $user, $factor, $password) |
|
50 | - { |
|
51 | - $storedData = $this->getCredentialData($user->getId()); |
|
52 | - |
|
53 | - if($storedData === null){ |
|
54 | - $storedData = $this->createNewCredential($user); |
|
55 | - } |
|
56 | - |
|
57 | - $storedData->setData(password_hash($password, PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))); |
|
58 | - $storedData->setFactor($factor); |
|
59 | - $storedData->setVersion(2); |
|
60 | - |
|
61 | - $storedData->save(); |
|
62 | - } |
|
17 | + const PASSWORD_COST = 10; |
|
18 | + |
|
19 | + public function __construct(PdoDatabase $database, SiteConfiguration $configuration) |
|
20 | + { |
|
21 | + parent::__construct($database, $configuration, 'password'); |
|
22 | + } |
|
23 | + |
|
24 | + public function authenticate(User $user, $data) |
|
25 | + { |
|
26 | + $storedData = $this->getCredentialData($user->getId()); |
|
27 | + if($storedData === null) |
|
28 | + { |
|
29 | + // No available credential matching these parameters |
|
30 | + return false; |
|
31 | + } |
|
32 | + |
|
33 | + if($storedData->getVersion() !== 2) { |
|
34 | + // Non-2 versions are not supported. |
|
35 | + return false; |
|
36 | + } |
|
37 | + |
|
38 | + if(password_verify($data, $storedData->getData())) { |
|
39 | + if(password_needs_rehash($storedData->getData(), PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))){ |
|
40 | + $this->setCredential($user, $storedData->getFactor(), $data); |
|
41 | + } |
|
42 | + |
|
43 | + return true; |
|
44 | + } |
|
45 | + |
|
46 | + return false; |
|
47 | + } |
|
48 | + |
|
49 | + public function setCredential(User $user, $factor, $password) |
|
50 | + { |
|
51 | + $storedData = $this->getCredentialData($user->getId()); |
|
52 | + |
|
53 | + if($storedData === null){ |
|
54 | + $storedData = $this->createNewCredential($user); |
|
55 | + } |
|
56 | + |
|
57 | + $storedData->setData(password_hash($password, PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))); |
|
58 | + $storedData->setFactor($factor); |
|
59 | + $storedData->setVersion(2); |
|
60 | + |
|
61 | + $storedData->save(); |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | \ No newline at end of file |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | public function authenticate(User $user, $data) |
25 | 25 | { |
26 | 26 | $storedData = $this->getCredentialData($user->getId()); |
27 | - if($storedData === null) |
|
27 | + if ($storedData === null) |
|
28 | 28 | { |
29 | 29 | // No available credential matching these parameters |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | - if($storedData->getVersion() !== 2) { |
|
33 | + if ($storedData->getVersion() !== 2) { |
|
34 | 34 | // Non-2 versions are not supported. |
35 | 35 | return false; |
36 | 36 | } |
37 | 37 | |
38 | - if(password_verify($data, $storedData->getData())) { |
|
39 | - if(password_needs_rehash($storedData->getData(), PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))){ |
|
38 | + if (password_verify($data, $storedData->getData())) { |
|
39 | + if (password_needs_rehash($storedData->getData(), PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))) { |
|
40 | 40 | $this->setCredential($user, $storedData->getFactor(), $data); |
41 | 41 | } |
42 | 42 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | $storedData = $this->getCredentialData($user->getId()); |
52 | 52 | |
53 | - if($storedData === null){ |
|
53 | + if ($storedData === null) { |
|
54 | 54 | $storedData = $this->createNewCredential($user); |
55 | 55 | } |
56 | 56 |
@@ -24,8 +24,7 @@ discard block |
||
24 | 24 | public function authenticate(User $user, $data) |
25 | 25 | { |
26 | 26 | $storedData = $this->getCredentialData($user->getId()); |
27 | - if($storedData === null) |
|
28 | - { |
|
27 | + if($storedData === null) { |
|
29 | 28 | // No available credential matching these parameters |
30 | 29 | return false; |
31 | 30 | } |
@@ -36,7 +35,7 @@ discard block |
||
36 | 35 | } |
37 | 36 | |
38 | 37 | if(password_verify($data, $storedData->getData())) { |
39 | - if(password_needs_rehash($storedData->getData(), PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))){ |
|
38 | + if(password_needs_rehash($storedData->getData(), PASSWORD_BCRYPT, array('cost' => self::PASSWORD_COST))) { |
|
40 | 39 | $this->setCredential($user, $storedData->getFactor(), $data); |
41 | 40 | } |
42 | 41 | |
@@ -50,7 +49,7 @@ discard block |
||
50 | 49 | { |
51 | 50 | $storedData = $this->getCredentialData($user->getId()); |
52 | 51 | |
53 | - if($storedData === null){ |
|
52 | + if($storedData === null) { |
|
54 | 53 | $storedData = $this->createNewCredential($user); |
55 | 54 | } |
56 | 55 |
@@ -15,85 +15,85 @@ |
||
15 | 15 | |
16 | 16 | abstract class CredentialProviderBase implements ICredentialProvider |
17 | 17 | { |
18 | - /** |
|
19 | - * @var PdoDatabase |
|
20 | - */ |
|
21 | - private $database; |
|
22 | - /** |
|
23 | - * @var SiteConfiguration |
|
24 | - */ |
|
25 | - private $configuration; |
|
26 | - /** @var string */ |
|
27 | - private $type; |
|
18 | + /** |
|
19 | + * @var PdoDatabase |
|
20 | + */ |
|
21 | + private $database; |
|
22 | + /** |
|
23 | + * @var SiteConfiguration |
|
24 | + */ |
|
25 | + private $configuration; |
|
26 | + /** @var string */ |
|
27 | + private $type; |
|
28 | 28 | |
29 | - /** |
|
30 | - * CredentialProviderBase constructor. |
|
31 | - * |
|
32 | - * @param PdoDatabase $database |
|
33 | - * @param SiteConfiguration $configuration |
|
34 | - * @param string $type |
|
35 | - */ |
|
36 | - public function __construct(PdoDatabase $database, SiteConfiguration $configuration, $type) |
|
37 | - { |
|
38 | - $this->database = $database; |
|
39 | - $this->configuration = $configuration; |
|
40 | - $this->type = $type; |
|
41 | - } |
|
29 | + /** |
|
30 | + * CredentialProviderBase constructor. |
|
31 | + * |
|
32 | + * @param PdoDatabase $database |
|
33 | + * @param SiteConfiguration $configuration |
|
34 | + * @param string $type |
|
35 | + */ |
|
36 | + public function __construct(PdoDatabase $database, SiteConfiguration $configuration, $type) |
|
37 | + { |
|
38 | + $this->database = $database; |
|
39 | + $this->configuration = $configuration; |
|
40 | + $this->type = $type; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param int $userId |
|
45 | - * |
|
46 | - * @return Credential |
|
47 | - */ |
|
48 | - protected function getCredentialData($userId) |
|
49 | - { |
|
50 | - $sql = 'SELECT * FROM credential WHERE type = :t AND user = :u AND disabled = 0'; |
|
43 | + /** |
|
44 | + * @param int $userId |
|
45 | + * |
|
46 | + * @return Credential |
|
47 | + */ |
|
48 | + protected function getCredentialData($userId) |
|
49 | + { |
|
50 | + $sql = 'SELECT * FROM credential WHERE type = :t AND user = :u AND disabled = 0'; |
|
51 | 51 | |
52 | - $statement = $this->database->prepare($sql); |
|
53 | - $statement->execute(array(':u' => $userId, ':t' => $this->type)); |
|
52 | + $statement = $this->database->prepare($sql); |
|
53 | + $statement->execute(array(':u' => $userId, ':t' => $this->type)); |
|
54 | 54 | |
55 | - /** @var Credential $obj */ |
|
56 | - $obj = $statement->fetchObject(Credential::class); |
|
55 | + /** @var Credential $obj */ |
|
56 | + $obj = $statement->fetchObject(Credential::class); |
|
57 | 57 | |
58 | - if ($obj === false) { |
|
59 | - return null; |
|
60 | - } |
|
58 | + if ($obj === false) { |
|
59 | + return null; |
|
60 | + } |
|
61 | 61 | |
62 | - $obj->setDatabase($this->database); |
|
62 | + $obj->setDatabase($this->database); |
|
63 | 63 | |
64 | - $statement->closeCursor(); |
|
64 | + $statement->closeCursor(); |
|
65 | 65 | |
66 | - return $obj; |
|
67 | - } |
|
66 | + return $obj; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return PdoDatabase |
|
71 | - */ |
|
72 | - public function getDatabase() |
|
73 | - { |
|
74 | - return $this->database; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return PdoDatabase |
|
71 | + */ |
|
72 | + public function getDatabase() |
|
73 | + { |
|
74 | + return $this->database; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return SiteConfiguration |
|
79 | - */ |
|
80 | - public function getConfiguration() |
|
81 | - { |
|
82 | - return $this->configuration; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return SiteConfiguration |
|
79 | + */ |
|
80 | + public function getConfiguration() |
|
81 | + { |
|
82 | + return $this->configuration; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param User $user |
|
87 | - * |
|
88 | - * @return Credential |
|
89 | - */ |
|
90 | - protected function createNewCredential(User $user) |
|
91 | - { |
|
92 | - $credential = new Credential(); |
|
93 | - $credential->setDatabase($this->getDatabase()); |
|
94 | - $credential->setUserId($user->getId()); |
|
95 | - $credential->setType($this->type); |
|
85 | + /** |
|
86 | + * @param User $user |
|
87 | + * |
|
88 | + * @return Credential |
|
89 | + */ |
|
90 | + protected function createNewCredential(User $user) |
|
91 | + { |
|
92 | + $credential = new Credential(); |
|
93 | + $credential->setDatabase($this->getDatabase()); |
|
94 | + $credential->setUserId($user->getId()); |
|
95 | + $credential->setType($this->type); |
|
96 | 96 | |
97 | - return $credential; |
|
98 | - } |
|
97 | + return $credential; |
|
98 | + } |
|
99 | 99 | } |
100 | 100 | \ No newline at end of file |
@@ -20,58 +20,58 @@ |
||
20 | 20 | */ |
21 | 21 | class StatsAction extends ApiPageBase implements IApiAction |
22 | 22 | { |
23 | - /** |
|
24 | - * The target user |
|
25 | - * @var User $user |
|
26 | - */ |
|
27 | - private $user; |
|
23 | + /** |
|
24 | + * The target user |
|
25 | + * @var User $user |
|
26 | + */ |
|
27 | + private $user; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Summary of execute |
|
31 | - * |
|
32 | - * @param \DOMElement $apiDocument |
|
33 | - * |
|
34 | - * @return \DOMElement |
|
35 | - * @throws ApiException |
|
36 | - * @throws \Exception |
|
37 | - */ |
|
38 | - public function executeApiAction(\DOMElement $apiDocument) |
|
39 | - { |
|
40 | - $username = WebRequest::getString('user'); |
|
41 | - $wikiusername = WebRequest::getString('wikiuser'); |
|
29 | + /** |
|
30 | + * Summary of execute |
|
31 | + * |
|
32 | + * @param \DOMElement $apiDocument |
|
33 | + * |
|
34 | + * @return \DOMElement |
|
35 | + * @throws ApiException |
|
36 | + * @throws \Exception |
|
37 | + */ |
|
38 | + public function executeApiAction(\DOMElement $apiDocument) |
|
39 | + { |
|
40 | + $username = WebRequest::getString('user'); |
|
41 | + $wikiusername = WebRequest::getString('wikiuser'); |
|
42 | 42 | |
43 | - if ($username === null && $wikiusername === null) { |
|
44 | - throw new ApiException("Please specify a username using either user or wikiuser parameters."); |
|
45 | - } |
|
43 | + if ($username === null && $wikiusername === null) { |
|
44 | + throw new ApiException("Please specify a username using either user or wikiuser parameters."); |
|
45 | + } |
|
46 | 46 | |
47 | - $userElement = $this->document->createElement("user"); |
|
48 | - $apiDocument->appendChild($userElement); |
|
47 | + $userElement = $this->document->createElement("user"); |
|
48 | + $apiDocument->appendChild($userElement); |
|
49 | 49 | |
50 | - if ($username !== null) { |
|
51 | - $user = User::getByUsername($username, $this->getDatabase()); |
|
52 | - } |
|
53 | - else { |
|
54 | - $user = User::getByOnWikiUsername($wikiusername, $this->getDatabase()); |
|
55 | - } |
|
50 | + if ($username !== null) { |
|
51 | + $user = User::getByUsername($username, $this->getDatabase()); |
|
52 | + } |
|
53 | + else { |
|
54 | + $user = User::getByOnWikiUsername($wikiusername, $this->getDatabase()); |
|
55 | + } |
|
56 | 56 | |
57 | - if ($user === false) { |
|
58 | - $userElement->setAttribute("missing", "true"); |
|
57 | + if ($user === false) { |
|
58 | + $userElement->setAttribute("missing", "true"); |
|
59 | 59 | |
60 | - return $apiDocument; |
|
61 | - } |
|
60 | + return $apiDocument; |
|
61 | + } |
|
62 | 62 | |
63 | - $this->user = $user; |
|
63 | + $this->user = $user; |
|
64 | 64 | |
65 | - $oauth = new OAuthUserHelper($user, $this->getDatabase(), $this->getOAuthProtocolHelper(), |
|
66 | - $this->getSiteConfiguration()); |
|
65 | + $oauth = new OAuthUserHelper($user, $this->getDatabase(), $this->getOAuthProtocolHelper(), |
|
66 | + $this->getSiteConfiguration()); |
|
67 | 67 | |
68 | - $userElement->setAttribute("username", $this->user->getUsername()); |
|
69 | - $userElement->setAttribute("status", $this->user->getStatus()); |
|
70 | - $userElement->setAttribute("lastactive", $this->user->getLastActive()); |
|
71 | - $userElement->setAttribute("welcome_template", $this->user->getWelcomeTemplate()); |
|
72 | - $userElement->setAttribute("onwikiname", $this->user->getOnWikiName()); |
|
73 | - $userElement->setAttribute("oauth", $oauth->isFullyLinked() ? "true" : "false"); |
|
68 | + $userElement->setAttribute("username", $this->user->getUsername()); |
|
69 | + $userElement->setAttribute("status", $this->user->getStatus()); |
|
70 | + $userElement->setAttribute("lastactive", $this->user->getLastActive()); |
|
71 | + $userElement->setAttribute("welcome_template", $this->user->getWelcomeTemplate()); |
|
72 | + $userElement->setAttribute("onwikiname", $this->user->getOnWikiName()); |
|
73 | + $userElement->setAttribute("oauth", $oauth->isFullyLinked() ? "true" : "false"); |
|
74 | 74 | |
75 | - return $apiDocument; |
|
76 | - } |
|
75 | + return $apiDocument; |
|
76 | + } |
|
77 | 77 | } |
@@ -19,52 +19,52 @@ |
||
19 | 19 | |
20 | 20 | interface IOAuthProtocolHelper |
21 | 21 | { |
22 | - /** |
|
23 | - * @return stdClass |
|
24 | - * |
|
25 | - * @throws Exception |
|
26 | - * @throws CurlException |
|
27 | - */ |
|
28 | - public function getRequestToken(); |
|
22 | + /** |
|
23 | + * @return stdClass |
|
24 | + * |
|
25 | + * @throws Exception |
|
26 | + * @throws CurlException |
|
27 | + */ |
|
28 | + public function getRequestToken(); |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param string $requestToken |
|
32 | - * |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function getAuthoriseUrl($requestToken); |
|
30 | + /** |
|
31 | + * @param string $requestToken |
|
32 | + * |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function getAuthoriseUrl($requestToken); |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param string $oauthRequestToken |
|
39 | - * @param string $oauthRequestSecret |
|
40 | - * @param string $oauthVerifier |
|
41 | - * |
|
42 | - * @return stdClass |
|
43 | - * @throws CurlException |
|
44 | - * @throws Exception |
|
45 | - */ |
|
46 | - public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier); |
|
37 | + /** |
|
38 | + * @param string $oauthRequestToken |
|
39 | + * @param string $oauthRequestSecret |
|
40 | + * @param string $oauthVerifier |
|
41 | + * |
|
42 | + * @return stdClass |
|
43 | + * @throws CurlException |
|
44 | + * @throws Exception |
|
45 | + */ |
|
46 | + public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier); |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param string $oauthAccessToken |
|
50 | - * @param string $oauthAccessSecret |
|
51 | - * |
|
52 | - * @return stdClass |
|
53 | - * @throws CurlException |
|
54 | - * @throws Exception |
|
55 | - */ |
|
56 | - public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret); |
|
48 | + /** |
|
49 | + * @param string $oauthAccessToken |
|
50 | + * @param string $oauthAccessSecret |
|
51 | + * |
|
52 | + * @return stdClass |
|
53 | + * @throws CurlException |
|
54 | + * @throws Exception |
|
55 | + */ |
|
56 | + public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret); |
|
57 | 57 | |
58 | - /** |
|
59 | - * @param array $apiParams array of parameters to send to the API |
|
60 | - * @param string $accessToken user's access token |
|
61 | - * @param string $accessSecret user's secret |
|
62 | - * @param string $method HTTP method |
|
63 | - * |
|
64 | - * @return stdClass |
|
65 | - * @throws ApplicationLogicException |
|
66 | - * @throws CurlException |
|
67 | - * @throws Exception |
|
68 | - */ |
|
69 | - public function apiCall($apiParams, $accessToken, $accessSecret, $method = 'GET'); |
|
58 | + /** |
|
59 | + * @param array $apiParams array of parameters to send to the API |
|
60 | + * @param string $accessToken user's access token |
|
61 | + * @param string $accessSecret user's secret |
|
62 | + * @param string $method HTTP method |
|
63 | + * |
|
64 | + * @return stdClass |
|
65 | + * @throws ApplicationLogicException |
|
66 | + * @throws CurlException |
|
67 | + * @throws Exception |
|
68 | + */ |
|
69 | + public function apiCall($apiParams, $accessToken, $accessSecret, $method = 'GET'); |
|
70 | 70 | } |
71 | 71 | \ No newline at end of file |
@@ -12,109 +12,109 @@ |
||
12 | 12 | |
13 | 13 | class HttpHelper |
14 | 14 | { |
15 | - private $curlHandle; |
|
16 | - |
|
17 | - /** |
|
18 | - * HttpHelper constructor. |
|
19 | - * |
|
20 | - * @param string $userAgent |
|
21 | - * @param boolean $disableVerifyPeer |
|
22 | - * @param string $cookieJar |
|
23 | - */ |
|
24 | - public function __construct($userAgent, $disableVerifyPeer, $cookieJar = null) |
|
25 | - { |
|
26 | - $this->curlHandle = curl_init(); |
|
27 | - |
|
28 | - curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, true); |
|
29 | - curl_setopt($this->curlHandle, CURLOPT_USERAGENT, $userAgent); |
|
30 | - curl_setopt($this->curlHandle, CURLOPT_FAILONERROR, true); |
|
31 | - |
|
32 | - if ($disableVerifyPeer) { |
|
33 | - curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYPEER, false); |
|
34 | - } |
|
35 | - |
|
36 | - if($cookieJar !== null) { |
|
37 | - curl_setopt($this->curlHandle, CURLOPT_COOKIEFILE, $cookieJar); |
|
38 | - curl_setopt($this->curlHandle, CURLOPT_COOKIEJAR, $cookieJar); |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - public function __destruct() |
|
43 | - { |
|
44 | - curl_close($this->curlHandle); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Fetches the content of a URL, with an optional parameter set. |
|
49 | - * |
|
50 | - * @param string $url The URL to fetch. |
|
51 | - * @param null|array $parameters Key/value pair of GET parameters to add to the request. |
|
52 | - * Null lets you handle it yourself. |
|
53 | - * |
|
54 | - * @param array $headers |
|
55 | - * |
|
56 | - * @return string |
|
57 | - * @throws CurlException |
|
58 | - */ |
|
59 | - public function get($url, $parameters = null, $headers = array()) |
|
60 | - { |
|
61 | - if ($parameters !== null && is_array($parameters)) { |
|
62 | - $getString = '?' . http_build_query($parameters); |
|
63 | - $url .= $getString; |
|
64 | - } |
|
65 | - |
|
66 | - curl_setopt($this->curlHandle, CURLOPT_URL, $url); |
|
67 | - |
|
68 | - // Make sure we're doing a GET |
|
69 | - curl_setopt($this->curlHandle, CURLOPT_POST, false); |
|
70 | - |
|
71 | - curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers); |
|
72 | - |
|
73 | - $result = curl_exec($this->curlHandle); |
|
74 | - |
|
75 | - if ($result === false) { |
|
76 | - $error = curl_error($this->curlHandle); |
|
77 | - throw new CurlException('Remote request failed with error ' . $error); |
|
78 | - } |
|
79 | - |
|
80 | - return $result; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * Posts data to a URL |
|
85 | - * |
|
86 | - * @param string $url The URL to fetch. |
|
87 | - * @param array $parameters Key/value pair of POST parameters to add to the request. |
|
88 | - * @param array $headers |
|
89 | - * |
|
90 | - * @return string |
|
91 | - * @throws CurlException |
|
92 | - */ |
|
93 | - public function post($url, $parameters, $headers = array()) |
|
94 | - { |
|
95 | - curl_setopt($this->curlHandle, CURLOPT_URL, $url); |
|
96 | - |
|
97 | - // Make sure we're doing a POST |
|
98 | - curl_setopt($this->curlHandle, CURLOPT_POST, true); |
|
99 | - curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, http_build_query($parameters)); |
|
100 | - |
|
101 | - curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers); |
|
102 | - |
|
103 | - $result = curl_exec($this->curlHandle); |
|
104 | - |
|
105 | - if ($result === false) { |
|
106 | - $error = curl_error($this->curlHandle); |
|
107 | - throw new CurlException('Remote request failed with error ' . $error); |
|
108 | - } |
|
109 | - |
|
110 | - return $result; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - public function getError() |
|
117 | - { |
|
118 | - return curl_error($this->curlHandle); |
|
119 | - } |
|
15 | + private $curlHandle; |
|
16 | + |
|
17 | + /** |
|
18 | + * HttpHelper constructor. |
|
19 | + * |
|
20 | + * @param string $userAgent |
|
21 | + * @param boolean $disableVerifyPeer |
|
22 | + * @param string $cookieJar |
|
23 | + */ |
|
24 | + public function __construct($userAgent, $disableVerifyPeer, $cookieJar = null) |
|
25 | + { |
|
26 | + $this->curlHandle = curl_init(); |
|
27 | + |
|
28 | + curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, true); |
|
29 | + curl_setopt($this->curlHandle, CURLOPT_USERAGENT, $userAgent); |
|
30 | + curl_setopt($this->curlHandle, CURLOPT_FAILONERROR, true); |
|
31 | + |
|
32 | + if ($disableVerifyPeer) { |
|
33 | + curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYPEER, false); |
|
34 | + } |
|
35 | + |
|
36 | + if($cookieJar !== null) { |
|
37 | + curl_setopt($this->curlHandle, CURLOPT_COOKIEFILE, $cookieJar); |
|
38 | + curl_setopt($this->curlHandle, CURLOPT_COOKIEJAR, $cookieJar); |
|
39 | + } |
|
40 | + } |
|
41 | + |
|
42 | + public function __destruct() |
|
43 | + { |
|
44 | + curl_close($this->curlHandle); |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Fetches the content of a URL, with an optional parameter set. |
|
49 | + * |
|
50 | + * @param string $url The URL to fetch. |
|
51 | + * @param null|array $parameters Key/value pair of GET parameters to add to the request. |
|
52 | + * Null lets you handle it yourself. |
|
53 | + * |
|
54 | + * @param array $headers |
|
55 | + * |
|
56 | + * @return string |
|
57 | + * @throws CurlException |
|
58 | + */ |
|
59 | + public function get($url, $parameters = null, $headers = array()) |
|
60 | + { |
|
61 | + if ($parameters !== null && is_array($parameters)) { |
|
62 | + $getString = '?' . http_build_query($parameters); |
|
63 | + $url .= $getString; |
|
64 | + } |
|
65 | + |
|
66 | + curl_setopt($this->curlHandle, CURLOPT_URL, $url); |
|
67 | + |
|
68 | + // Make sure we're doing a GET |
|
69 | + curl_setopt($this->curlHandle, CURLOPT_POST, false); |
|
70 | + |
|
71 | + curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers); |
|
72 | + |
|
73 | + $result = curl_exec($this->curlHandle); |
|
74 | + |
|
75 | + if ($result === false) { |
|
76 | + $error = curl_error($this->curlHandle); |
|
77 | + throw new CurlException('Remote request failed with error ' . $error); |
|
78 | + } |
|
79 | + |
|
80 | + return $result; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * Posts data to a URL |
|
85 | + * |
|
86 | + * @param string $url The URL to fetch. |
|
87 | + * @param array $parameters Key/value pair of POST parameters to add to the request. |
|
88 | + * @param array $headers |
|
89 | + * |
|
90 | + * @return string |
|
91 | + * @throws CurlException |
|
92 | + */ |
|
93 | + public function post($url, $parameters, $headers = array()) |
|
94 | + { |
|
95 | + curl_setopt($this->curlHandle, CURLOPT_URL, $url); |
|
96 | + |
|
97 | + // Make sure we're doing a POST |
|
98 | + curl_setopt($this->curlHandle, CURLOPT_POST, true); |
|
99 | + curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, http_build_query($parameters)); |
|
100 | + |
|
101 | + curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers); |
|
102 | + |
|
103 | + $result = curl_exec($this->curlHandle); |
|
104 | + |
|
105 | + if ($result === false) { |
|
106 | + $error = curl_error($this->curlHandle); |
|
107 | + throw new CurlException('Remote request failed with error ' . $error); |
|
108 | + } |
|
109 | + |
|
110 | + return $result; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + public function getError() |
|
117 | + { |
|
118 | + return curl_error($this->curlHandle); |
|
119 | + } |
|
120 | 120 | } |
121 | 121 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYPEER, false); |
34 | 34 | } |
35 | 35 | |
36 | - if($cookieJar !== null) { |
|
36 | + if ($cookieJar !== null) { |
|
37 | 37 | curl_setopt($this->curlHandle, CURLOPT_COOKIEFILE, $cookieJar); |
38 | 38 | curl_setopt($this->curlHandle, CURLOPT_COOKIEJAR, $cookieJar); |
39 | 39 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function get($url, $parameters = null, $headers = array()) |
60 | 60 | { |
61 | 61 | if ($parameters !== null && is_array($parameters)) { |
62 | - $getString = '?' . http_build_query($parameters); |
|
62 | + $getString = '?'.http_build_query($parameters); |
|
63 | 63 | $url .= $getString; |
64 | 64 | } |
65 | 65 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | if ($result === false) { |
76 | 76 | $error = curl_error($this->curlHandle); |
77 | - throw new CurlException('Remote request failed with error ' . $error); |
|
77 | + throw new CurlException('Remote request failed with error '.$error); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | return $result; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | if ($result === false) { |
106 | 106 | $error = curl_error($this->curlHandle); |
107 | - throw new CurlException('Remote request failed with error ' . $error); |
|
107 | + throw new CurlException('Remote request failed with error '.$error); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | return $result; |
@@ -241,7 +241,8 @@ |
||
241 | 241 | * @param string $username |
242 | 242 | * @return bool |
243 | 243 | */ |
244 | - public function checkAccountExists($username) { |
|
244 | + public function checkAccountExists($username) |
|
245 | + { |
|
245 | 246 | $parameters = array( |
246 | 247 | 'action' => 'query', |
247 | 248 | 'list' => 'users', |
@@ -15,245 +15,245 @@ |
||
15 | 15 | |
16 | 16 | class MediaWikiHelper |
17 | 17 | { |
18 | - /** |
|
19 | - * @var IMediaWikiClient |
|
20 | - */ |
|
21 | - private $mediaWikiClient; |
|
22 | - /** |
|
23 | - * @var SiteConfiguration |
|
24 | - */ |
|
25 | - private $siteConfiguration; |
|
26 | - |
|
27 | - /** |
|
28 | - * MediaWikiHelper constructor. |
|
29 | - * |
|
30 | - * @param IMediaWikiClient $mediaWikiClient |
|
31 | - * @param SiteConfiguration $siteConfiguration |
|
32 | - */ |
|
33 | - public function __construct(IMediaWikiClient $mediaWikiClient, SiteConfiguration $siteConfiguration) |
|
34 | - { |
|
35 | - $this->mediaWikiClient = $mediaWikiClient; |
|
36 | - $this->siteConfiguration = $siteConfiguration; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * @todo handle override antispoof and titleblacklist issues |
|
41 | - * |
|
42 | - * @param string $username |
|
43 | - * @param string $emailAddress |
|
44 | - * @param string $reason |
|
45 | - * |
|
46 | - * @throws Exception |
|
47 | - * @throws MediaWikiApiException |
|
48 | - */ |
|
49 | - public function createAccount($username, $emailAddress, $reason) |
|
50 | - { |
|
51 | - // get token |
|
52 | - $tokenParams = array( |
|
53 | - 'action' => 'query', |
|
54 | - 'meta' => 'tokens', |
|
55 | - 'type' => 'createaccount', |
|
56 | - ); |
|
57 | - |
|
58 | - $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
|
59 | - |
|
60 | - if (isset($response->error)) { |
|
61 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
62 | - } |
|
63 | - |
|
64 | - $token = $response->query->tokens->createaccounttoken; |
|
65 | - |
|
66 | - $callback = $this->siteConfiguration->getBaseUrl() . '/internal.php/oauth/createCallback'; |
|
67 | - |
|
68 | - $checkboxFields = array(); |
|
69 | - $requiredFields = array(); |
|
70 | - $this->getCreationFieldData($requiredFields, $checkboxFields); |
|
71 | - |
|
72 | - $apiCallData = array( |
|
73 | - 'action' => 'createaccount', |
|
74 | - 'createreturnurl' => $callback, |
|
75 | - 'createtoken' => $token, |
|
76 | - 'createmessageformat' => 'html', |
|
77 | - ); |
|
78 | - |
|
79 | - $createParams = array_fill_keys($requiredFields, '') + $apiCallData; |
|
80 | - |
|
81 | - $createParams['username'] = $username; |
|
82 | - $createParams['mailpassword'] = true; |
|
83 | - $createParams['email'] = $emailAddress; |
|
84 | - $createParams['reason'] = $reason; |
|
85 | - |
|
86 | - $createResponse = $this->mediaWikiClient->doApiCall($createParams, 'POST'); |
|
87 | - |
|
88 | - if (isset($createResponse->error)) { |
|
89 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
90 | - } |
|
91 | - |
|
92 | - if (!isset($createResponse->createaccount) || !isset($createResponse->createaccount->status)) { |
|
93 | - throw new MediaWikiApiException('Unknown error creating account'); |
|
94 | - } |
|
95 | - |
|
96 | - if ($createResponse->createaccount->status === 'FAIL') { |
|
97 | - throw new MediaWikiApiException($createResponse->createaccount->message); |
|
98 | - } |
|
99 | - |
|
100 | - if ($createResponse->createaccount->status === 'PASS') { |
|
101 | - // success! |
|
102 | - return; |
|
103 | - } |
|
104 | - |
|
105 | - throw new Exception('API result reported status of ' . $createResponse->createaccount->status); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $username |
|
110 | - * @param string $title |
|
111 | - * @param $summary |
|
112 | - * @param string $message |
|
113 | - * @param bool $createOnly |
|
114 | - * |
|
115 | - * @throws MediaWikiApiException |
|
116 | - */ |
|
117 | - public function addTalkPageMessage($username, $title, $summary, $message, $createOnly = true) |
|
118 | - { |
|
119 | - // get token |
|
120 | - $tokenParams = array( |
|
121 | - 'action' => 'query', |
|
122 | - 'meta' => 'tokens', |
|
123 | - 'type' => 'csrf', |
|
124 | - ); |
|
125 | - |
|
126 | - $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
|
127 | - |
|
128 | - if (isset($response->error)) { |
|
129 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
130 | - } |
|
131 | - |
|
132 | - $token = $response->query->tokens->csrftoken; |
|
133 | - |
|
134 | - if ($token === null) { |
|
135 | - throw new MediaWikiApiException('Edit token could not be acquired'); |
|
136 | - } |
|
137 | - |
|
138 | - $editParameters = array( |
|
139 | - 'action' => 'edit', |
|
140 | - 'title' => 'User talk:' . $username, |
|
141 | - 'section' => 'new', |
|
142 | - 'sectiontitle' => $title, |
|
143 | - 'summary' => $summary, |
|
144 | - 'text' => $message, |
|
145 | - 'token' => $token, |
|
146 | - ); |
|
147 | - |
|
148 | - if ($createOnly) { |
|
149 | - $editParameters['createonly'] = true; |
|
150 | - } |
|
151 | - |
|
152 | - $response = $this->mediaWikiClient->doApiCall($editParameters, 'POST'); |
|
153 | - |
|
154 | - if (!isset($response->edit)) { |
|
155 | - if (isset($response->error)) { |
|
156 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
157 | - } |
|
158 | - |
|
159 | - throw new MediaWikiApiException('Unknown error encountered during editing.'); |
|
160 | - } |
|
161 | - |
|
162 | - $editResponse = $response->edit; |
|
163 | - if ($editResponse->result === "Success") { |
|
164 | - return; |
|
165 | - } |
|
166 | - |
|
167 | - throw new MediaWikiApiException('Edit status unsuccessful: ' . $editResponse->result); |
|
168 | - } |
|
169 | - |
|
170 | - public function getCreationFieldData(&$requiredFields, &$checkboxFields) |
|
171 | - { |
|
172 | - // get token |
|
173 | - $params = array( |
|
174 | - 'action' => 'query', |
|
175 | - 'meta' => 'authmanagerinfo', |
|
176 | - 'amirequestsfor' => 'create', |
|
177 | - ); |
|
178 | - |
|
179 | - $response = $this->mediaWikiClient->doApiCall($params, 'GET'); |
|
180 | - |
|
181 | - if (isset($response->error)) { |
|
182 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
183 | - } |
|
184 | - |
|
185 | - $requests = $response->query->authmanagerinfo->requests; |
|
186 | - |
|
187 | - // We don't want to deal with these providers ever. |
|
188 | - $discardList = array( |
|
189 | - // Requires a username and password |
|
190 | - 'MediaWiki\\Auth\\PasswordAuthenticationRequest', |
|
191 | - ); |
|
192 | - |
|
193 | - // We require these providers to function |
|
194 | - $requireList = array( |
|
195 | - 'MediaWiki\\Auth\\TemporaryPasswordAuthenticationRequest', |
|
196 | - 'MediaWiki\\Auth\\UsernameAuthenticationRequest', |
|
197 | - 'MediaWiki\\Auth\\UserDataAuthenticationRequest', |
|
198 | - 'MediaWiki\\Auth\\CreationReasonAuthenticationRequest', |
|
199 | - ); |
|
200 | - |
|
201 | - $requiredFields = array(); |
|
202 | - // Keep checkbox fields separate, since "required" actually means optional as absent == false. |
|
203 | - $checkboxFields = array(); |
|
204 | - |
|
205 | - foreach ($requests as $req) { |
|
206 | - // Immediately discard anything that is on the discard list. |
|
207 | - if (in_array($req->id, $discardList)) { |
|
208 | - continue; |
|
209 | - } |
|
210 | - |
|
211 | - $required = false; |
|
212 | - |
|
213 | - if ($req->required === 'primary-required' && !in_array($req->id, $requireList)) { |
|
214 | - // Only want one. |
|
215 | - continue; |
|
216 | - } |
|
217 | - |
|
218 | - if (in_array($req->id, $requireList)) { |
|
219 | - unset($requireList[$req->id]); |
|
220 | - $required = true; |
|
221 | - } |
|
222 | - |
|
223 | - if ($req->required === 'required') { |
|
224 | - $required = true; |
|
225 | - } |
|
226 | - |
|
227 | - if ($required) { |
|
228 | - foreach ($req->fields as $name => $data) { |
|
229 | - if ($data->type === 'checkbox') { |
|
230 | - $checkboxFields[] = $name; |
|
231 | - } |
|
232 | - else { |
|
233 | - $requiredFields[] = $name; |
|
234 | - } |
|
235 | - } |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * @param string $username |
|
242 | - * @return bool |
|
243 | - */ |
|
244 | - public function checkAccountExists($username) { |
|
245 | - $parameters = array( |
|
246 | - 'action' => 'query', |
|
247 | - 'list' => 'users', |
|
248 | - 'format' => 'php', |
|
249 | - 'ususers' => $username, |
|
250 | - ); |
|
251 | - |
|
252 | - $apiResult = $this->mediaWikiClient->doApiCall($parameters, 'GET'); |
|
253 | - |
|
254 | - $entry = $apiResult->query->users[0]; |
|
255 | - $exists = !isset($entry->missing); |
|
256 | - |
|
257 | - return $exists; |
|
258 | - } |
|
18 | + /** |
|
19 | + * @var IMediaWikiClient |
|
20 | + */ |
|
21 | + private $mediaWikiClient; |
|
22 | + /** |
|
23 | + * @var SiteConfiguration |
|
24 | + */ |
|
25 | + private $siteConfiguration; |
|
26 | + |
|
27 | + /** |
|
28 | + * MediaWikiHelper constructor. |
|
29 | + * |
|
30 | + * @param IMediaWikiClient $mediaWikiClient |
|
31 | + * @param SiteConfiguration $siteConfiguration |
|
32 | + */ |
|
33 | + public function __construct(IMediaWikiClient $mediaWikiClient, SiteConfiguration $siteConfiguration) |
|
34 | + { |
|
35 | + $this->mediaWikiClient = $mediaWikiClient; |
|
36 | + $this->siteConfiguration = $siteConfiguration; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * @todo handle override antispoof and titleblacklist issues |
|
41 | + * |
|
42 | + * @param string $username |
|
43 | + * @param string $emailAddress |
|
44 | + * @param string $reason |
|
45 | + * |
|
46 | + * @throws Exception |
|
47 | + * @throws MediaWikiApiException |
|
48 | + */ |
|
49 | + public function createAccount($username, $emailAddress, $reason) |
|
50 | + { |
|
51 | + // get token |
|
52 | + $tokenParams = array( |
|
53 | + 'action' => 'query', |
|
54 | + 'meta' => 'tokens', |
|
55 | + 'type' => 'createaccount', |
|
56 | + ); |
|
57 | + |
|
58 | + $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
|
59 | + |
|
60 | + if (isset($response->error)) { |
|
61 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
62 | + } |
|
63 | + |
|
64 | + $token = $response->query->tokens->createaccounttoken; |
|
65 | + |
|
66 | + $callback = $this->siteConfiguration->getBaseUrl() . '/internal.php/oauth/createCallback'; |
|
67 | + |
|
68 | + $checkboxFields = array(); |
|
69 | + $requiredFields = array(); |
|
70 | + $this->getCreationFieldData($requiredFields, $checkboxFields); |
|
71 | + |
|
72 | + $apiCallData = array( |
|
73 | + 'action' => 'createaccount', |
|
74 | + 'createreturnurl' => $callback, |
|
75 | + 'createtoken' => $token, |
|
76 | + 'createmessageformat' => 'html', |
|
77 | + ); |
|
78 | + |
|
79 | + $createParams = array_fill_keys($requiredFields, '') + $apiCallData; |
|
80 | + |
|
81 | + $createParams['username'] = $username; |
|
82 | + $createParams['mailpassword'] = true; |
|
83 | + $createParams['email'] = $emailAddress; |
|
84 | + $createParams['reason'] = $reason; |
|
85 | + |
|
86 | + $createResponse = $this->mediaWikiClient->doApiCall($createParams, 'POST'); |
|
87 | + |
|
88 | + if (isset($createResponse->error)) { |
|
89 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
90 | + } |
|
91 | + |
|
92 | + if (!isset($createResponse->createaccount) || !isset($createResponse->createaccount->status)) { |
|
93 | + throw new MediaWikiApiException('Unknown error creating account'); |
|
94 | + } |
|
95 | + |
|
96 | + if ($createResponse->createaccount->status === 'FAIL') { |
|
97 | + throw new MediaWikiApiException($createResponse->createaccount->message); |
|
98 | + } |
|
99 | + |
|
100 | + if ($createResponse->createaccount->status === 'PASS') { |
|
101 | + // success! |
|
102 | + return; |
|
103 | + } |
|
104 | + |
|
105 | + throw new Exception('API result reported status of ' . $createResponse->createaccount->status); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $username |
|
110 | + * @param string $title |
|
111 | + * @param $summary |
|
112 | + * @param string $message |
|
113 | + * @param bool $createOnly |
|
114 | + * |
|
115 | + * @throws MediaWikiApiException |
|
116 | + */ |
|
117 | + public function addTalkPageMessage($username, $title, $summary, $message, $createOnly = true) |
|
118 | + { |
|
119 | + // get token |
|
120 | + $tokenParams = array( |
|
121 | + 'action' => 'query', |
|
122 | + 'meta' => 'tokens', |
|
123 | + 'type' => 'csrf', |
|
124 | + ); |
|
125 | + |
|
126 | + $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
|
127 | + |
|
128 | + if (isset($response->error)) { |
|
129 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
130 | + } |
|
131 | + |
|
132 | + $token = $response->query->tokens->csrftoken; |
|
133 | + |
|
134 | + if ($token === null) { |
|
135 | + throw new MediaWikiApiException('Edit token could not be acquired'); |
|
136 | + } |
|
137 | + |
|
138 | + $editParameters = array( |
|
139 | + 'action' => 'edit', |
|
140 | + 'title' => 'User talk:' . $username, |
|
141 | + 'section' => 'new', |
|
142 | + 'sectiontitle' => $title, |
|
143 | + 'summary' => $summary, |
|
144 | + 'text' => $message, |
|
145 | + 'token' => $token, |
|
146 | + ); |
|
147 | + |
|
148 | + if ($createOnly) { |
|
149 | + $editParameters['createonly'] = true; |
|
150 | + } |
|
151 | + |
|
152 | + $response = $this->mediaWikiClient->doApiCall($editParameters, 'POST'); |
|
153 | + |
|
154 | + if (!isset($response->edit)) { |
|
155 | + if (isset($response->error)) { |
|
156 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
157 | + } |
|
158 | + |
|
159 | + throw new MediaWikiApiException('Unknown error encountered during editing.'); |
|
160 | + } |
|
161 | + |
|
162 | + $editResponse = $response->edit; |
|
163 | + if ($editResponse->result === "Success") { |
|
164 | + return; |
|
165 | + } |
|
166 | + |
|
167 | + throw new MediaWikiApiException('Edit status unsuccessful: ' . $editResponse->result); |
|
168 | + } |
|
169 | + |
|
170 | + public function getCreationFieldData(&$requiredFields, &$checkboxFields) |
|
171 | + { |
|
172 | + // get token |
|
173 | + $params = array( |
|
174 | + 'action' => 'query', |
|
175 | + 'meta' => 'authmanagerinfo', |
|
176 | + 'amirequestsfor' => 'create', |
|
177 | + ); |
|
178 | + |
|
179 | + $response = $this->mediaWikiClient->doApiCall($params, 'GET'); |
|
180 | + |
|
181 | + if (isset($response->error)) { |
|
182 | + throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
183 | + } |
|
184 | + |
|
185 | + $requests = $response->query->authmanagerinfo->requests; |
|
186 | + |
|
187 | + // We don't want to deal with these providers ever. |
|
188 | + $discardList = array( |
|
189 | + // Requires a username and password |
|
190 | + 'MediaWiki\\Auth\\PasswordAuthenticationRequest', |
|
191 | + ); |
|
192 | + |
|
193 | + // We require these providers to function |
|
194 | + $requireList = array( |
|
195 | + 'MediaWiki\\Auth\\TemporaryPasswordAuthenticationRequest', |
|
196 | + 'MediaWiki\\Auth\\UsernameAuthenticationRequest', |
|
197 | + 'MediaWiki\\Auth\\UserDataAuthenticationRequest', |
|
198 | + 'MediaWiki\\Auth\\CreationReasonAuthenticationRequest', |
|
199 | + ); |
|
200 | + |
|
201 | + $requiredFields = array(); |
|
202 | + // Keep checkbox fields separate, since "required" actually means optional as absent == false. |
|
203 | + $checkboxFields = array(); |
|
204 | + |
|
205 | + foreach ($requests as $req) { |
|
206 | + // Immediately discard anything that is on the discard list. |
|
207 | + if (in_array($req->id, $discardList)) { |
|
208 | + continue; |
|
209 | + } |
|
210 | + |
|
211 | + $required = false; |
|
212 | + |
|
213 | + if ($req->required === 'primary-required' && !in_array($req->id, $requireList)) { |
|
214 | + // Only want one. |
|
215 | + continue; |
|
216 | + } |
|
217 | + |
|
218 | + if (in_array($req->id, $requireList)) { |
|
219 | + unset($requireList[$req->id]); |
|
220 | + $required = true; |
|
221 | + } |
|
222 | + |
|
223 | + if ($req->required === 'required') { |
|
224 | + $required = true; |
|
225 | + } |
|
226 | + |
|
227 | + if ($required) { |
|
228 | + foreach ($req->fields as $name => $data) { |
|
229 | + if ($data->type === 'checkbox') { |
|
230 | + $checkboxFields[] = $name; |
|
231 | + } |
|
232 | + else { |
|
233 | + $requiredFields[] = $name; |
|
234 | + } |
|
235 | + } |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * @param string $username |
|
242 | + * @return bool |
|
243 | + */ |
|
244 | + public function checkAccountExists($username) { |
|
245 | + $parameters = array( |
|
246 | + 'action' => 'query', |
|
247 | + 'list' => 'users', |
|
248 | + 'format' => 'php', |
|
249 | + 'ususers' => $username, |
|
250 | + ); |
|
251 | + |
|
252 | + $apiResult = $this->mediaWikiClient->doApiCall($parameters, 'GET'); |
|
253 | + |
|
254 | + $entry = $apiResult->query->users[0]; |
|
255 | + $exists = !isset($entry->missing); |
|
256 | + |
|
257 | + return $exists; |
|
258 | + } |
|
259 | 259 | } |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
59 | 59 | |
60 | 60 | if (isset($response->error)) { |
61 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
61 | + throw new MediaWikiApiException($response->error->code.': '.$response->error->info); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $token = $response->query->tokens->createaccounttoken; |
65 | 65 | |
66 | - $callback = $this->siteConfiguration->getBaseUrl() . '/internal.php/oauth/createCallback'; |
|
66 | + $callback = $this->siteConfiguration->getBaseUrl().'/internal.php/oauth/createCallback'; |
|
67 | 67 | |
68 | 68 | $checkboxFields = array(); |
69 | 69 | $requiredFields = array(); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $createResponse = $this->mediaWikiClient->doApiCall($createParams, 'POST'); |
87 | 87 | |
88 | 88 | if (isset($createResponse->error)) { |
89 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
89 | + throw new MediaWikiApiException($response->error->code.': '.$response->error->info); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | if (!isset($createResponse->createaccount) || !isset($createResponse->createaccount->status)) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | return; |
103 | 103 | } |
104 | 104 | |
105 | - throw new Exception('API result reported status of ' . $createResponse->createaccount->status); |
|
105 | + throw new Exception('API result reported status of '.$createResponse->createaccount->status); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $response = $this->mediaWikiClient->doApiCall($tokenParams, 'POST'); |
127 | 127 | |
128 | 128 | if (isset($response->error)) { |
129 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
129 | + throw new MediaWikiApiException($response->error->code.': '.$response->error->info); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $token = $response->query->tokens->csrftoken; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | $editParameters = array( |
139 | 139 | 'action' => 'edit', |
140 | - 'title' => 'User talk:' . $username, |
|
140 | + 'title' => 'User talk:'.$username, |
|
141 | 141 | 'section' => 'new', |
142 | 142 | 'sectiontitle' => $title, |
143 | 143 | 'summary' => $summary, |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | if (!isset($response->edit)) { |
155 | 155 | if (isset($response->error)) { |
156 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
156 | + throw new MediaWikiApiException($response->error->code.': '.$response->error->info); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | throw new MediaWikiApiException('Unknown error encountered during editing.'); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | return; |
165 | 165 | } |
166 | 166 | |
167 | - throw new MediaWikiApiException('Edit status unsuccessful: ' . $editResponse->result); |
|
167 | + throw new MediaWikiApiException('Edit status unsuccessful: '.$editResponse->result); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | public function getCreationFieldData(&$requiredFields, &$checkboxFields) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $response = $this->mediaWikiClient->doApiCall($params, 'GET'); |
180 | 180 | |
181 | 181 | if (isset($response->error)) { |
182 | - throw new MediaWikiApiException($response->error->code . ': ' . $response->error->info); |
|
182 | + throw new MediaWikiApiException($response->error->code.': '.$response->error->info); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | $requests = $response->query->authmanagerinfo->requests; |