@@ -44,10 +44,10 @@ |
||
| 44 | 44 | public function stampsProvider(): array |
| 45 | 45 | { |
| 46 | 46 | return [ |
| 47 | - [ time() + 10, 20, true], |
|
| 48 | - [ time() - 10, 20, true], |
|
| 49 | - [ time() + 50, 20, false], |
|
| 50 | - [ time() - 50, 20, false], |
|
| 47 | + [time() + 10, 20, true], |
|
| 48 | + [time() - 10, 20, true], |
|
| 49 | + [time() + 50, 20, false], |
|
| 50 | + [time() - 50, 20, false], |
|
| 51 | 51 | ]; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | //create signature |
| 53 | 53 | $privateKey = openssl_pkey_new([ |
| 54 | - "private_key_bits" => 1024, # not need too long for testing purposes |
|
| 54 | + "private_key_bits" => 1024, # not need too long for testing purposes |
|
| 55 | 55 | "private_key_type" => OPENSSL_KEYTYPE_RSA, |
| 56 | 56 | ]); |
| 57 | 57 | $privateData = openssl_pkey_get_details($privateKey); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | // now query itself |
| 66 | 66 | $urlSource = new Sources\Sources(); |
| 67 | 67 | $urlSource->setAddress($this->signLink($privateKey, '/dummy/?user=testing&pass=asdf123ghjk456×tamp=123456', 'qwertziop')); |
| 68 | - $method = new Methods\UrlCerts(new \MockAuthCert($mockUser, ''), null, new Handler($urlSource) ); |
|
| 68 | + $method = new Methods\UrlCerts(new \MockAuthCert($mockUser, ''), null, new Handler($urlSource)); |
|
| 69 | 69 | $method->process(new \MockCredentials([Methods\UrlHash::INPUT_NAME => 'testing', Methods\UrlHash::INPUT_STAMP => time(), ])); |
| 70 | 70 | $this->assertTrue($method->isAuthorized()); |
| 71 | 71 | $method->remove(); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | //create signature |
| 89 | 89 | $privateKey = openssl_pkey_new([ |
| 90 | - "private_key_bits" => 1024, # not need too long for testing purposes |
|
| 90 | + "private_key_bits" => 1024, # not need too long for testing purposes |
|
| 91 | 91 | "private_key_type" => OPENSSL_KEYTYPE_RSA, |
| 92 | 92 | ]); |
| 93 | 93 | $privateData = openssl_pkey_get_details($privateKey); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | // now query itself |
| 111 | 111 | $method = new Methods\HttpCerts(new \MockAuthCert($mockUser, ''), null, new Handler($urlSource), new \MockCredentials( |
| 112 | 112 | [Methods\HttpCerts::INPUT_NAME => 'testing', Methods\HttpCerts::INPUT_PASS => rawurlencode(base64_encode($signature)), ] |
| 113 | - ) ); |
|
| 113 | + )); |
|
| 114 | 114 | $method->process(new \MockCredentials()); |
| 115 | 115 | $this->assertTrue($method->isAuthorized()); |
| 116 | 116 | } |
@@ -43,9 +43,9 @@ |
||
| 43 | 43 | |
| 44 | 44 | public function process(\ArrayAccess $credentials): void |
| 45 | 45 | { |
| 46 | - $name = $credentials->offsetExists(static::INPUT_NAME) ? strval($credentials->offsetGet(static::INPUT_NAME)) : '' ; |
|
| 47 | - $name = $credentials->offsetExists(static::INPUT_NAME2) ? strval($credentials->offsetGet(static::INPUT_NAME2)) : $name ; |
|
| 48 | - $stamp = $credentials->offsetExists(static::INPUT_STAMP) ? intval(strval($credentials->offsetGet(static::INPUT_STAMP))) : 0 ; |
|
| 46 | + $name = $credentials->offsetExists(static::INPUT_NAME) ? strval($credentials->offsetGet(static::INPUT_NAME)) : ''; |
|
| 47 | + $name = $credentials->offsetExists(static::INPUT_NAME2) ? strval($credentials->offsetGet(static::INPUT_NAME2)) : $name; |
|
| 48 | + $stamp = $credentials->offsetExists(static::INPUT_STAMP) ? intval(strval($credentials->offsetGet(static::INPUT_STAMP))) : 0; |
|
| 49 | 49 | |
| 50 | 50 | $wantedUser = $this->authenticator->getCertData(strval($name)); |
| 51 | 51 | if ($wantedUser && !empty($stamp) && $this->checkStamp($stamp)) { |
@@ -93,7 +93,7 @@ |
||
| 93 | 93 | preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]*?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
| 94 | 94 | |
| 95 | 95 | foreach ($matches as $m) { |
| 96 | - $data[strval($m[1])] = strval($m[3] ?: ( $m[4] ?? '' )); |
|
| 96 | + $data[strval($m[1])] = strval($m[3] ?: ($m[4] ?? '')); |
|
| 97 | 97 | unset($needed_parts[$m[1]]); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | |
| 82 | 82 | public function process(\ArrayAccess $credentials): void |
| 83 | 83 | { |
| 84 | - $name = $credentials->offsetExists(static::INPUT_NAME) ? strval($credentials->offsetGet(static::INPUT_NAME)) : '' ; |
|
| 84 | + $name = $credentials->offsetExists(static::INPUT_NAME) ? strval($credentials->offsetGet(static::INPUT_NAME)) : ''; |
|
| 85 | 85 | $ip = strval($this->server->offsetGet(static::SERVER_REMOTE)); |
| 86 | 86 | if ($this->libBan->has( |
| 87 | 87 | strval(preg_replace(static::PREG_IP4, '', $ip)), |
@@ -53,9 +53,9 @@ |
||
| 53 | 53 | |
| 54 | 54 | public function process(\ArrayAccess $credentials): void |
| 55 | 55 | { |
| 56 | - $name = $credentials->offsetExists(static::INPUT_NAME) ? strval($credentials->offsetGet(static::INPUT_NAME)) : '' ; |
|
| 57 | - $name = $credentials->offsetExists(static::INPUT_NAME2) ? strval($credentials->offsetGet(static::INPUT_NAME2) ): $name ; |
|
| 58 | - $stamp = $credentials->offsetExists(static::INPUT_STAMP) ? intval(strval($credentials->offsetGet(static::INPUT_STAMP))) : 0 ; |
|
| 56 | + $name = $credentials->offsetExists(static::INPUT_NAME) ? strval($credentials->offsetGet(static::INPUT_NAME)) : ''; |
|
| 57 | + $name = $credentials->offsetExists(static::INPUT_NAME2) ? strval($credentials->offsetGet(static::INPUT_NAME2)) : $name; |
|
| 58 | + $stamp = $credentials->offsetExists(static::INPUT_STAMP) ? intval(strval($credentials->offsetGet(static::INPUT_STAMP))) : 0; |
|
| 59 | 59 | |
| 60 | 60 | $wantedUser = $this->authenticator->getCertData(strval($name)); |
| 61 | 61 | if ($wantedUser && !empty($stamp) && $this->checkStamp($stamp)) { |
@@ -42,8 +42,8 @@ |
||
| 42 | 42 | |
| 43 | 43 | public function process(\ArrayAccess $credentials): void |
| 44 | 44 | { |
| 45 | - $name = $this->server->offsetExists(static::INPUT_NAME) ? strval($this->server->offsetGet(static::INPUT_NAME)) : '' ; |
|
| 46 | - $digest = $this->server->offsetExists(static::INPUT_PASS) ? strval($this->server->offsetGet(static::INPUT_PASS)) : '' ; |
|
| 45 | + $name = $this->server->offsetExists(static::INPUT_NAME) ? strval($this->server->offsetGet(static::INPUT_NAME)) : ''; |
|
| 46 | + $digest = $this->server->offsetExists(static::INPUT_PASS) ? strval($this->server->offsetGet(static::INPUT_PASS)) : ''; |
|
| 47 | 47 | $wantedUser = $this->authenticator->getCertData(strval($name)); |
| 48 | 48 | if ($wantedUser && $digest) { |
| 49 | 49 | // now we have public key and salt from our storage, so it's time to check it |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | public function setExpirationNotice($class, int $nextChange): void |
| 34 | 34 | { |
| 35 | 35 | if ($class && is_object($class) && $class instanceof IExpire) { |
| 36 | - $class->setExpireNotice( $this->shallExpire($nextChange)); |
|
| 36 | + $class->setExpireNotice($this->shallExpire($nextChange)); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -51,14 +51,14 @@ |
||
| 51 | 51 | { |
| 52 | 52 | $ln = strlen($input); |
| 53 | 53 | # pass is too long and salt too short |
| 54 | - $salt = (strlen($this->salt) < ($ln*5)) |
|
| 54 | + $salt = (strlen($this->salt) < ($ln * 5)) |
|
| 55 | 55 | ? str_repeat($this->salt, 5) |
| 56 | - : $this->salt ; |
|
| 56 | + : $this->salt; |
|
| 57 | 57 | return substr($salt, $ln, $ln) |
| 58 | - . substr($input,0, (int) ($ln/2)) |
|
| 59 | - . substr($salt,$ln*2, $ln) |
|
| 60 | - . substr($input, (int) ($ln/2)) |
|
| 61 | - . substr($salt,$ln*3, $ln); |
|
| 58 | + . substr($input, 0, (int) ($ln / 2)) |
|
| 59 | + . substr($salt, $ln * 2, $ln) |
|
| 60 | + . substr($input, (int) ($ln / 2)) |
|
| 61 | + . substr($salt, $ln * 3, $ln); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |