@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * Check if a custom scope is set |
65 | 65 | */ |
66 | - if( isset($this->header->getMethod()->data['scope']) && |
|
66 | + if (isset($this->header->getMethod()->data['scope']) && |
|
67 | 67 | ($this->header->getMethod()->data['scope'] == 'anonymous') |
68 | 68 | ) { |
69 | 69 | $this->grantAccess = true; |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | ->decode() |
102 | 102 | ; |
103 | 103 | |
104 | - if( isset($decoded['sub']) && !empty($decoded['sub']) ) { |
|
104 | + if (isset($decoded['sub']) && !empty($decoded['sub'])) { |
|
105 | 105 | |
106 | 106 | $this->user = (object) (new user\user) |
107 | 107 | ->setOptions($this->getOptions()) |
108 | 108 | ->load($decoded['sub'], ['refreshToken' => true]) |
109 | 109 | ; |
110 | 110 | |
111 | - if ( !empty($this->user) ) { |
|
111 | + if (!empty($this->user)) { |
|
112 | 112 | $jwt = new auth\jwt; |
113 | 113 | $decoded = $jwt |
114 | 114 | ->setOptions($this->getOptions()) |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | ->decode() |
118 | 118 | ; |
119 | 119 | } |
120 | - }else{ |
|
120 | + } else { |
|
121 | 121 | |
122 | 122 | $this->header->unauthorised(); |
123 | 123 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * [$user Check user account] |
128 | 128 | * @var [object] |
129 | 129 | */ |
130 | - if ( (isset($decoded['sub']) && !empty($decoded['sub'])) && !$this->user ) { |
|
130 | + if ((isset($decoded['sub']) && !empty($decoded['sub'])) && !$this->user) { |
|
131 | 131 | $this->user = (object) (new user\user) |
132 | 132 | ->setOptions($this->getOptions()) |
133 | 133 | ->load($decoded['sub'], ['refreshToken' => true]) |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function user() |
150 | 150 | { |
151 | - if( $this->isGrantType() ) { |
|
151 | + if ($this->isGrantType()) { |
|
152 | 152 | return (object) [ |
153 | 153 | 'uid' => -1, |
154 | 154 | 'account_id' => 0, |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | - if( isset($this->header->getMethod()->data['scope']) && |
|
180 | + if (isset($this->header->getMethod()->data['scope']) && |
|
181 | 181 | ($this->header->getMethod()->data['scope'] == 'anonymous') |
182 | 182 | ) { |
183 | 183 | return; |
@@ -117,7 +117,7 @@ |
||
117 | 117 | ->decode() |
118 | 118 | ; |
119 | 119 | } |
120 | - }else{ |
|
120 | + } else{ |
|
121 | 121 | |
122 | 122 | $this->header->unauthorised(); |
123 | 123 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | public function apiKeyGenerate($length = 32) |
37 | 37 | { |
38 | - $randInt = microtime().rand(1000, 9999); |
|
38 | + $randInt = microtime() . rand(1000, 9999); |
|
39 | 39 | $messageDigest = md5($randInt); |
40 | 40 | return implode( |
41 | 41 | '-', |
@@ -215,7 +215,7 @@ |
||
215 | 215 | if ($nLeakRate < 0) { |
216 | 216 | $nLeakRate = 0; |
217 | 217 | } |
218 | - $this->leakage = (float)$nLeakRate; |
|
218 | + $this->leakage = (float) $nLeakRate; |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 |
@@ -138,7 +138,7 @@ |
||
138 | 138 | |
139 | 139 | if (is_numeric($timeframe)) { |
140 | 140 | if ($timeframe < 0) { |
141 | - $timeframe = ($timeframe*-1); |
|
141 | + $timeframe = ($timeframe * -1); |
|
142 | 142 | } |
143 | 143 | self::$timeframe['CUSTOM'] = $timeframe; |
144 | 144 | $this->window = intval(self::$timeframe['CUSTOM']); |
@@ -66,7 +66,7 @@ |
||
66 | 66 | */ |
67 | 67 | public static function payload(array $payloadObject = []) |
68 | 68 | { |
69 | - if( self::isAnonymousScope($payloadObject) ) { |
|
69 | + if (self::isAnonymousScope($payloadObject)) { |
|
70 | 70 | return true; |
71 | 71 | } |
72 | 72 |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | $this->secret = $this->getDefaults()['config']['MASTER_KEY']; |
101 | 101 | |
102 | - if( isset($options['secret']) && $options['secret'] == 'append' ) { |
|
102 | + if (isset($options['secret']) && $options['secret'] == 'append') { |
|
103 | 103 | $this->secretAppend = true; |
104 | 104 | } |
105 | 105 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | \PDO::FETCH_OBJ |
139 | 139 | ); |
140 | 140 | |
141 | - if( $this->secretAppend ) { |
|
141 | + if ($this->secretAppend) { |
|
142 | 142 | $this->secret = $account->secret; |
143 | 143 | } |
144 | 144 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $headers->setOptions($this->getOptions()); |
154 | 154 | $sentToken = $headers->hasBearerToken(); |
155 | 155 | |
156 | - if( $sentToken ) { |
|
156 | + if ($sentToken) { |
|
157 | 157 | /** |
158 | 158 | * [$jwt Decode the JWT] |
159 | 159 | * @var auth\jwt |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | ; |
172 | 172 | $absSeconds = ($decoded['exp'] - ($this->timeNow() - $leeway)); |
173 | 173 | |
174 | - if( $absSeconds > 0 ) { |
|
174 | + if ($absSeconds > 0) { |
|
175 | 175 | $account->JWT = $sentToken; |
176 | 176 | } |
177 | 177 | |
@@ -215,21 +215,21 @@ discard block |
||
215 | 215 | public function refreshTokenGenerate($account) |
216 | 216 | { |
217 | 217 | $offset = 86400; |
218 | - $time = ($this->timeNow()+$offset); |
|
218 | + $time = ($this->timeNow() + $offset); |
|
219 | 219 | |
220 | - if( isset($account->refresh_token) && !empty($account->refresh_token) ) { |
|
220 | + if (isset($account->refresh_token) && !empty($account->refresh_token)) { |
|
221 | 221 | $raToken = explode('.', $account->refresh_token); |
222 | - if( !empty($raToken) ) { |
|
222 | + if (!empty($raToken)) { |
|
223 | 223 | $raToken = array_values(array_filter($raToken)); |
224 | - $time = ($raToken[0] <= ($this->timeNow()-$offset) ) ? ($this->timeNow()+$offset) : $raToken[0]; |
|
224 | + $time = ($raToken[0] <= ($this->timeNow() - $offset)) ? ($this->timeNow() + $offset) : $raToken[0]; |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | $cipher = new encoder\cipher; |
229 | - $refreshHash = $account->account_id.':'.$account->secret; |
|
229 | + $refreshHash = $account->account_id . ':' . $account->secret; |
|
230 | 230 | $refreshHash = $cipher->encode($cipher->hash('sha256', $refreshHash, $account->secret)); |
231 | 231 | |
232 | - $refreshHash = $time.'.'.$refreshHash; |
|
232 | + $refreshHash = $time . '.' . $refreshHash; |
|
233 | 233 | $account->refreshToken = $refreshHash; |
234 | 234 | |
235 | 235 | $updateProp = [ |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | /** |
302 | 302 | * Check token expiry |
303 | 303 | */ |
304 | - if($this->checkVal($userPayload['payload'], 'exp') && !$skipExpiry) { |
|
304 | + if ($this->checkVal($userPayload['payload'], 'exp') && !$skipExpiry) { |
|
305 | 305 | return $this->refreshJWT($userPayload); |
306 | 306 | } |
307 | 307 | |
@@ -365,26 +365,26 @@ discard block |
||
365 | 365 | $payload['iat'] = $iat; |
366 | 366 | } |
367 | 367 | if (false !== ($nbf = $this->checkVal($jwtOptions, 'notBeFor'))) { |
368 | - if( strtolower($nbf) == 'issuedat' && isset($payload['iat']) ) { |
|
368 | + if (strtolower($nbf) == 'issuedat' && isset($payload['iat'])) { |
|
369 | 369 | $nbf = $payload['iat'] + 10; |
370 | 370 | } |
371 | 371 | $payload['nbf'] = $nbf; |
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | - if( $refresh && $exp ) { |
|
375 | + if ($refresh && $exp) { |
|
376 | 376 | $refreshPayload = $payload; |
377 | 377 | |
378 | 378 | $offset = $exp - $this->timeNow(); |
379 | 379 | $leeway = ($this->checkVal($this->options['jwt'], 'leeway')) ?: $this->jwt->getLeeway(); |
380 | 380 | |
381 | - $refreshPayload['exp'] = $exp+$offset+$leeway; |
|
381 | + $refreshPayload['exp'] = $exp + $offset + $leeway; |
|
382 | 382 | |
383 | 383 | $refreshJWT = $this->refreshJWT([ |
384 | 384 | 'payload' => $refreshPayload |
385 | 385 | ]); |
386 | 386 | |
387 | - if( isset($refreshJWT['refresh']) ) { |
|
387 | + if (isset($refreshJWT['refresh'])) { |
|
388 | 388 | return $refreshJWT['refresh']; |
389 | 389 | } |
390 | 390 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $bucket->getTokenData() |
212 | 212 | ); |
213 | 213 | |
214 | - if($this->isMockTest) { |
|
214 | + if ($this->isMockTest) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function getAccount() |
259 | 259 | { |
260 | - if($this->isMockTest) { |
|
260 | + if ($this->isMockTest) { |
|
261 | 261 | $this->getMockAccount(); |
262 | 262 | } |
263 | 263 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | $mockAccount = []; |
283 | 283 | |
284 | - if(!isset($mockAccount['bucket'])) { |
|
284 | + if (!isset($mockAccount['bucket'])) { |
|
285 | 285 | $mockAccount['bucket'] = $packer->pack( |
286 | 286 | $bucket->getTokenData() |
287 | 287 | ); |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | |
290 | 290 | $mockAccount['access'] = time(); |
291 | 291 | |
292 | - $this->setAccount((object)$mockAccount); |
|
293 | - $this->mockAccount = (object)$mockAccount; |
|
292 | + $this->setAccount((object) $mockAccount); |
|
293 | + $this->mockAccount = (object) $mockAccount; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -51,7 +51,7 @@ |
||
51 | 51 | $payloadObject = $cipher->jsonDecode($cipher->decode($jwtPayload)); |
52 | 52 | |
53 | 53 | // @codeCoverageIgnoreStart |
54 | - if( $this->key == 'payloadOnly' ) { |
|
54 | + if ($this->key == 'payloadOnly') { |
|
55 | 55 | return $payloadObject; |
56 | 56 | } |
57 | 57 | // @codeCoverageIgnoreEnd |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @var array |
53 | 53 | */ |
54 | 54 | protected static $ALGORITHMS = [ |
55 | - 'HS256','sha256', |
|
56 | - 'HS384','sha384', |
|
57 | - 'HS512','sha512', |
|
55 | + 'HS256', 'sha256', |
|
56 | + 'HS384', 'sha384', |
|
57 | + 'HS512', 'sha512', |
|
58 | 58 | ]; |
59 | 59 | |
60 | 60 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * [getOptions] |
253 | 253 | * @return array |
254 | 254 | */ |
255 | - public function getOptions():?array |
|
255 | + public function getOptions(): ?array |
|
256 | 256 | { |
257 | 257 | return self::$options; |
258 | 258 | } |