@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | private function _getStringValue(string $columnName, string $userId): string |
| 84 | 84 | { |
| 85 | - if ( !in_array($columnName, $this->_allowedStringColumns) ) { |
|
| 85 | + if (!in_array($columnName, $this->_allowedStringColumns)) { |
|
| 86 | 86 | throw new InvalidArgumentException('Unsupported column name'); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | try { |
| 90 | - $sth = $this->handle->prepare('SELECT ' . $columnName . ' FROM ' . $this->tablename . ' WHERE userid = ?'); |
|
| 90 | + $sth = $this->handle->prepare('SELECT '.$columnName.' FROM '.$this->tablename.' WHERE userid = ?'); |
|
| 91 | 91 | $sth->execute(array($userId)); |
| 92 | - $res=$sth->fetchColumn(); |
|
| 92 | + $res = $sth->fetchColumn(); |
|
| 93 | 93 | if ($res === false) { |
| 94 | 94 | // No result |
| 95 | 95 | $this->logger->error(sprintf('No result getting "%s" for user "%s"', $columnName, $userId)); |
| 96 | 96 | throw new RuntimeException('User not found'); |
| 97 | 97 | } |
| 98 | 98 | if ($res === NULL) { |
| 99 | - return ''; // Value unset |
|
| 99 | + return ''; // Value unset |
|
| 100 | 100 | } |
| 101 | 101 | if (!is_string($res)) { |
| 102 | 102 | $this->logger->error(sprintf('Expected string type while getting "%s" for user "%s"', $columnName, $userId)); |
@@ -120,28 +120,28 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | private function _getIntValue(string $columnName, string $userId): int |
| 122 | 122 | { |
| 123 | - if ( !in_array($columnName, $this->_allowedIntColumns) ) { |
|
| 123 | + if (!in_array($columnName, $this->_allowedIntColumns)) { |
|
| 124 | 124 | throw new InvalidArgumentException('Unsupported column name'); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | try { |
| 128 | - $sth = $this->handle->prepare('SELECT ' . $columnName . ' FROM ' . $this->tablename . ' WHERE userid = ?'); |
|
| 128 | + $sth = $this->handle->prepare('SELECT '.$columnName.' FROM '.$this->tablename.' WHERE userid = ?'); |
|
| 129 | 129 | $sth->execute(array($userId)); |
| 130 | - $res=$sth->fetchColumn(); |
|
| 130 | + $res = $sth->fetchColumn(); |
|
| 131 | 131 | if ($res === false) { |
| 132 | 132 | // No result |
| 133 | 133 | $this->logger->error(sprintf('No result getting "%s" for user "%s"', $columnName, $userId)); |
| 134 | 134 | throw new RuntimeException('User not found'); |
| 135 | 135 | } |
| 136 | 136 | if ($res === NULL) { |
| 137 | - return 0; // Value unset |
|
| 137 | + return 0; // Value unset |
|
| 138 | 138 | } |
| 139 | 139 | // Return type for integers depends on the PDO driver, can be string |
| 140 | 140 | if (!is_numeric($res)) { |
| 141 | 141 | $this->logger->error(sprintf('Expected int type while getting "%s" for user "%s"', $columnName, $userId)); |
| 142 | 142 | throw new RuntimeException('Unexpected return type'); |
| 143 | 143 | } |
| 144 | - return (int)$res; |
|
| 144 | + return (int) $res; |
|
| 145 | 145 | } |
| 146 | 146 | catch (Exception $e) { |
| 147 | 147 | $this->logger->error('PDO error getting user', array('exception' => $e, 'userId' => $userId, 'columnName'=>$columnName)); |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | */ |
| 159 | 159 | private function _setStringValue(string $columnName, string $userId, string $value): void |
| 160 | 160 | { |
| 161 | - if ( !in_array($columnName, $this->_allowedStringColumns) ) { |
|
| 161 | + if (!in_array($columnName, $this->_allowedStringColumns)) { |
|
| 162 | 162 | throw new InvalidArgumentException('Unsupported column name'); |
| 163 | 163 | } |
| 164 | 164 | try { |
| 165 | - $sth = $this->handle->prepare('UPDATE ' . $this->tablename . ' SET ' . $columnName . ' = ? WHERE userid = ?'); |
|
| 165 | + $sth = $this->handle->prepare('UPDATE '.$this->tablename.' SET '.$columnName.' = ? WHERE userid = ?'); |
|
| 166 | 166 | $sth->execute(array($value, $userId)); |
| 167 | 167 | if ($sth->rowCount() == 0) { |
| 168 | 168 | throw new RuntimeException('User not found'); |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | private function _setIntValue(string $columnName, string $userId, int $value): void |
| 185 | 185 | { |
| 186 | - if ( !in_array($columnName, $this->_allowedIntColumns) ) { |
|
| 186 | + if (!in_array($columnName, $this->_allowedIntColumns)) { |
|
| 187 | 187 | throw new InvalidArgumentException('Unsupported column name'); |
| 188 | 188 | } |
| 189 | 189 | try { |
| 190 | - $sth = $this->handle->prepare('UPDATE ' . $this->tablename . ' SET ' . $columnName . ' = ? WHERE userid = ?'); |
|
| 190 | + $sth = $this->handle->prepare('UPDATE '.$this->tablename.' SET '.$columnName.' = ? WHERE userid = ?'); |
|
| 191 | 191 | $sth->execute(array($value, $userId)); |
| 192 | 192 | if ($sth->rowCount() == 0) { |
| 193 | 193 | throw new RuntimeException('User not found'); |
@@ -296,17 +296,17 @@ discard block |
||
| 296 | 296 | { |
| 297 | 297 | // Check for blocked |
| 298 | 298 | if ($this->_getIntValue('blocked', $userId) != 0) { |
| 299 | - return true; // Blocked |
|
| 299 | + return true; // Blocked |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | if (0 == $tempBlockDuration) { |
| 303 | - return false; // No check for temporary block |
|
| 303 | + return false; // No check for temporary block |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // Check for temporary block |
| 307 | 307 | $timestamp = $this->getTemporaryBlockTimestamp($userId); |
| 308 | 308 | // if no temporary block timestamp is set or if the temporary block is expired, return false |
| 309 | - if ( 0 == $timestamp || ($timestamp + $tempBlockDuration * 60) < time()) { |
|
| 309 | + if (0 == $timestamp || ($timestamp + $tempBlockDuration * 60) < time()) { |
|
| 310 | 310 | return false; |
| 311 | 311 | } |
| 312 | 312 | return true; |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * @throws ReadWriteException |
| 30 | 30 | * @throws Exception |
| 31 | 31 | */ |
| 32 | - public function setValue(string $key, $value, int $expire=0): void; |
|
| 32 | + public function setValue(string $key, $value, int $expire = 0): void; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Remove $key from the state storage |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
| 49 | 49 | */ |
| 50 | - public function setValue(string $key, $value, int $expire=0): void |
|
| 50 | + public function setValue(string $key, $value, int $expire = 0): void |
|
| 51 | 51 | { |
| 52 | 52 | if (empty($key)) { |
| 53 | 53 | throw new InvalidArgumentException('Empty key not allowed'); |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | private function getPath(): string |
| 111 | 111 | { |
| 112 | - if (substr($this->path, -1)!=="/") { |
|
| 113 | - return $this->path . "/"; |
|
| 112 | + if (substr($this->path, -1) !== "/") { |
|
| 113 | + return $this->path."/"; |
|
| 114 | 114 | } |
| 115 | 115 | return $this->path; |
| 116 | 116 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * The default configuration |
| 52 | 52 | */ |
| 53 | 53 | const DEFAULT_HOST = '127.0.0.1'; |
| 54 | - const DEFAULT_PORT = 11211; |
|
| 54 | + const DEFAULT_PORT = 11211; |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Get the prefix to use for all keys in memcache. |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
| 105 | 105 | */ |
| 106 | - public function setValue(string $key, $value, int $expire=0): void |
|
| 106 | + public function setValue(string $key, $value, int $expire = 0): void |
|
| 107 | 107 | { |
| 108 | 108 | if (empty($key)) { |
| 109 | 109 | throw new InvalidArgumentException('Empty key not allowed'); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | if ($result === false) { |
| 158 | 158 | // Memcache interface does not provide error information, either the key does not exists or |
| 159 | 159 | // there was an error communicating with the memcache |
| 160 | - $this->logger->info( sprintf('Unable to get key "%s" from memcache StateStorage', $key) ); |
|
| 160 | + $this->logger->info(sprintf('Unable to get key "%s" from memcache StateStorage', $key)); |
|
| 161 | 161 | return null; |
| 162 | 162 | } |
| 163 | 163 | return $result; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | throw new InvalidArgumentException('Empty key not allowed'); |
| 78 | 78 | } |
| 79 | 79 | try { |
| 80 | - $sth = $this->handle->prepare('SELECT `key` FROM ' . $this->tablename . ' WHERE `key` = ?'); |
|
| 80 | + $sth = $this->handle->prepare('SELECT `key` FROM '.$this->tablename.' WHERE `key` = ?'); |
|
| 81 | 81 | $sth->execute(array($key)); |
| 82 | 82 | return $sth->fetchColumn() !== false; |
| 83 | 83 | } |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | private function cleanExpired(): void { |
| 99 | 99 | try { |
| 100 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `expire` < ? AND NOT `expire` = 0"); |
|
| 100 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `expire` < ? AND NOT `expire` = 0"); |
|
| 101 | 101 | $sth->execute(array(time())); |
| 102 | - $deletedRows=$sth->rowCount(); |
|
| 102 | + $deletedRows = $sth->rowCount(); |
|
| 103 | 103 | $this->logger->notice( |
| 104 | 104 | sprintf("Deleted %i expired keys", $deletedRows) |
| 105 | 105 | ); |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | /** |
| 116 | 116 | * @see Tiqr_StateStorage_StateStorageInterface::setValue() |
| 117 | 117 | */ |
| 118 | - public function setValue(string $key, $value, int $expire=0): void |
|
| 118 | + public function setValue(string $key, $value, int $expire = 0): void |
|
| 119 | 119 | { |
| 120 | 120 | if (empty($key)) { |
| 121 | 121 | throw new InvalidArgumentException('Empty key not allowed'); |
| 122 | 122 | } |
| 123 | - if (((float) rand() /(float) getrandmax()) < $this->cleanupProbability) { |
|
| 123 | + if (((float) rand() / (float) getrandmax()) < $this->cleanupProbability) { |
|
| 124 | 124 | $this->cleanExpired(); |
| 125 | 125 | } |
| 126 | 126 | if ($this->keyExists($key)) { |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | // $expire == 0 means never expire |
| 132 | 132 | if ($expire != 0) { |
| 133 | - $expire+=time(); // Store unix timestamp after which the expires |
|
| 133 | + $expire += time(); // Store unix timestamp after which the expires |
|
| 134 | 134 | } |
| 135 | 135 | try { |
| 136 | 136 | $sth->execute(array(serialize($value), $expire, $key)); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | throw new InvalidArgumentException('Empty key not allowed'); |
| 154 | 154 | } |
| 155 | 155 | try { |
| 156 | - $sth = $this->handle->prepare("DELETE FROM " . $this->tablename . " WHERE `key` = ?"); |
|
| 156 | + $sth = $this->handle->prepare("DELETE FROM ".$this->tablename." WHERE `key` = ?"); |
|
| 157 | 157 | $sth->execute(array($key)); |
| 158 | 158 | } |
| 159 | 159 | catch (Exception $e) { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | try { |
| 186 | - $sth = $this->handle->prepare('SELECT `value` FROM ' . $this->tablename . ' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
| 186 | + $sth = $this->handle->prepare('SELECT `value` FROM '.$this->tablename.' WHERE `key` = ? AND (`expire` >= ? OR `expire` = 0)'); |
|
| 187 | 187 | $sth->execute(array($key, time())); |
| 188 | 188 | } |
| 189 | 189 | catch (Exception $e) { |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | if (false === $result) { |
| 198 | 198 | // Occurs normally |
| 199 | 199 | $this->logger->info(sprintf('getValue: Key "%s" not found in PDO StateStorage', $key)); |
| 200 | - return NULL; // Key not found |
|
| 200 | + return NULL; // Key not found |
|
| 201 | 201 | } |
| 202 | - $result=unserialize($result, array('allowed_classes' => false)); |
|
| 202 | + $result = unserialize($result, array('allowed_classes' => false)); |
|
| 203 | 203 | if (false === $result) { |
| 204 | 204 | throw new RuntimeException(sprintf('getValue: unserialize error for key "%s" in PDO StateStorage', $key)); |
| 205 | 205 | } |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | * @return Tiqr_OcraService_Interface |
| 40 | 40 | * @throws Exception An exception if an unknown orca service type is requested. |
| 41 | 41 | */ |
| 42 | - public static function getOcraService(string $type="tiqr", array $options=array(), LoggerInterface $logger) |
|
| 42 | + public static function getOcraService(string $type = "tiqr", array $options = array(), LoggerInterface $logger) |
|
| 43 | 43 | { |
| 44 | 44 | switch ($type) { |
| 45 | 45 | case "tiqr": |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param array $options |
| 194 | 194 | * @param int $version The protocol version to use (defaults to the latest) |
| 195 | 195 | */ |
| 196 | - public function __construct(LoggerInterface $logger, $options=array(), $version = 2) |
|
| 196 | + public function __construct(LoggerInterface $logger, $options = array(), $version = 2) |
|
| 197 | 197 | { |
| 198 | 198 | $this->_options = $options; |
| 199 | 199 | $this->logger = $logger; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | $this->logger->info(sprintf('Creating and sending a %s push notification', $notificationType)); |
| 348 | 348 | $message->setId(time()); |
| 349 | - $message->setText("Please authenticate for " . $this->_name); |
|
| 349 | + $message->setText("Please authenticate for ".$this->_name); |
|
| 350 | 350 | $message->setAddress($notificationAddress); |
| 351 | 351 | $message->setCustomProperty('challenge', $this->_getChallengeUrl($sessionKey)); |
| 352 | 352 | $message->send(); |
@@ -417,13 +417,13 @@ discard block |
||
| 417 | 417 | * @return Session key |
| 418 | 418 | * @throws Exception |
| 419 | 419 | */ |
| 420 | - public function startAuthenticationSession(string $userId="", string $sessionId="", string $spIdentifier=""): string |
|
| 420 | + public function startAuthenticationSession(string $userId = "", string $sessionId = "", string $spIdentifier = ""): string |
|
| 421 | 421 | { |
| 422 | - if ($sessionId=="") { |
|
| 422 | + if ($sessionId == "") { |
|
| 423 | 423 | $sessionId = session_id(); |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if ($spIdentifier=="") { |
|
| 426 | + if ($spIdentifier == "") { |
|
| 427 | 427 | $spIdentifier = $this->_identifier; |
| 428 | 428 | } |
| 429 | 429 | |
@@ -433,11 +433,11 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | $data = array("sessionId"=>$sessionId, "challenge"=>$challenge, "spIdentifier" => $spIdentifier); |
| 435 | 435 | |
| 436 | - if ($userId!="") { |
|
| 436 | + if ($userId != "") { |
|
| 437 | 437 | $data["userId"] = $userId; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - $this->_stateStorage->setValue(self::PREFIX_CHALLENGE . $sessionKey, $data, self::CHALLENGE_EXPIRE); |
|
| 440 | + $this->_stateStorage->setValue(self::PREFIX_CHALLENGE.$sessionKey, $data, self::CHALLENGE_EXPIRE); |
|
| 441 | 441 | |
| 442 | 442 | return $sessionKey; |
| 443 | 443 | } |
@@ -457,9 +457,9 @@ discard block |
||
| 457 | 457 | * to php session) |
| 458 | 458 | * @return String The enrollment key |
| 459 | 459 | */ |
| 460 | - public function startEnrollmentSession(string $userId, string $displayName, string $sessionId="") |
|
| 460 | + public function startEnrollmentSession(string $userId, string $displayName, string $sessionId = "") |
|
| 461 | 461 | { |
| 462 | - if ($sessionId=="") { |
|
| 462 | + if ($sessionId == "") { |
|
| 463 | 463 | $sessionId = session_id(); |
| 464 | 464 | } |
| 465 | 465 | $enrollmentKey = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT); |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | "displayName" => $displayName, |
| 469 | 469 | "sessionId" => $sessionId |
| 470 | 470 | ]; |
| 471 | - $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT . $enrollmentKey, $data, self::ENROLLMENT_EXPIRE); |
|
| 471 | + $this->_stateStorage->setValue(self::PREFIX_ENROLLMENT.$enrollmentKey, $data, self::ENROLLMENT_EXPIRE); |
|
| 472 | 472 | $this->_setEnrollmentStatus($sessionId, self::ENROLLMENT_STATUS_INITIALIZED); |
| 473 | 473 | |
| 474 | 474 | return $enrollmentKey; |
@@ -479,9 +479,9 @@ discard block |
||
| 479 | 479 | * @param $sessionId The application's session identifier (defaults |
| 480 | 480 | * to php session) |
| 481 | 481 | */ |
| 482 | - public function resetEnrollmentSession($sessionId="") |
|
| 482 | + public function resetEnrollmentSession($sessionId = "") |
|
| 483 | 483 | { |
| 484 | - if ($sessionId=="") { |
|
| 484 | + if ($sessionId == "") { |
|
| 485 | 485 | $sessionId = session_id(); |
| 486 | 486 | } |
| 487 | 487 | |
@@ -515,9 +515,9 @@ discard block |
||
| 515 | 515 | * |
| 516 | 516 | * Does not throw |
| 517 | 517 | */ |
| 518 | - public function getEnrollmentStatus(string $sessionId=""): int |
|
| 518 | + public function getEnrollmentStatus(string $sessionId = ""): int |
|
| 519 | 519 | { |
| 520 | - if ($sessionId=="") { |
|
| 520 | + if ($sessionId == "") { |
|
| 521 | 521 | $sessionId = session_id(); |
| 522 | 522 | } |
| 523 | 523 | $status = $this->_stateStorage->getValue("enrollstatus".$sessionId); |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | */ |
| 578 | 578 | public function getEnrollmentMetadata($enrollmentKey, $authenticationUrl, $enrollmentUrl): array |
| 579 | 579 | { |
| 580 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 580 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey); |
|
| 581 | 581 | if (!is_array($data)) { |
| 582 | 582 | $this->logger->error('Unable to find enrollment metadata in state storage'); |
| 583 | 583 | throw new Exception('Unable to find enrollment metadata in state storage'); |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | array("identifier" =>$data["userId"], |
| 597 | 597 | "displayName"=>$data["displayName"])); |
| 598 | 598 | |
| 599 | - $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 599 | + $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT.$enrollmentKey); |
|
| 600 | 600 | |
| 601 | 601 | $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_RETRIEVED); |
| 602 | 602 | return $metadata; |
@@ -618,14 +618,14 @@ discard block |
||
| 618 | 618 | */ |
| 619 | 619 | public function getEnrollmentSecret(string $enrollmentKey): string |
| 620 | 620 | { |
| 621 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 621 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT.$enrollmentKey); |
|
| 622 | 622 | $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
| 623 | 623 | $enrollmentData = [ |
| 624 | 624 | "userId" => $data["userId"], |
| 625 | 625 | "sessionId" => $data["sessionId"] |
| 626 | 626 | ]; |
| 627 | 627 | $this->_stateStorage->setValue( |
| 628 | - self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
| 628 | + self::PREFIX_ENROLLMENT_SECRET.$secret, |
|
| 629 | 629 | $enrollmentData, |
| 630 | 630 | self::ENROLLMENT_EXPIRE |
| 631 | 631 | ); |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
| 676 | 676 | } else { |
| 677 | 677 | $this->logger->error( |
| 678 | - 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
| 678 | + 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. '. |
|
| 679 | 679 | 'Warning! the method will still return "true" as a result.' |
| 680 | 680 | ); |
| 681 | 681 | } |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | */ |
| 706 | 706 | public function authenticate($userId, $userSecret, $sessionKey, $response) |
| 707 | 707 | { |
| 708 | - $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey); |
|
| 708 | + $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey); |
|
| 709 | 709 | if (is_null($state)) { |
| 710 | 710 | $this->logger->info('The auth challenge could not be found in the state storage'); |
| 711 | 711 | return self::AUTH_RESULT_INVALID_CHALLENGE; |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | $challengeUserId = $state["userId"]; |
| 720 | 720 | } |
| 721 | 721 | // Check if we're dealing with a second factor |
| 722 | - if ($challengeUserId!=NULL && ($userId != $challengeUserId)) { |
|
| 722 | + if ($challengeUserId != NULL && ($userId != $challengeUserId)) { |
|
| 723 | 723 | $this->logger->error( |
| 724 | 724 | 'Authentication failed: the first factor user id does not match with that of the second factor' |
| 725 | 725 | ); |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | $this->_stateStorage->setValue("authenticated_".$sessionId, $userId, self::LOGIN_EXPIRE); |
| 738 | 738 | |
| 739 | 739 | // Clean up the challenge. |
| 740 | - $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE . $sessionKey); |
|
| 740 | + $this->_stateStorage->unsetValue(self::PREFIX_CHALLENGE.$sessionKey); |
|
| 741 | 741 | $this->logger->info('Authentication succeeded'); |
| 742 | 742 | return self::AUTH_RESULT_AUTHENTICATED; |
| 743 | 743 | } |
@@ -750,9 +750,9 @@ discard block |
||
| 750 | 750 | * @param String $sessionId The application's session identifier (defaults |
| 751 | 751 | * to the php session). |
| 752 | 752 | */ |
| 753 | - public function logout($sessionId="") |
|
| 753 | + public function logout($sessionId = "") |
|
| 754 | 754 | { |
| 755 | - if ($sessionId=="") { |
|
| 755 | + if ($sessionId == "") { |
|
| 756 | 756 | $sessionId = session_id(); |
| 757 | 757 | } |
| 758 | 758 | |
@@ -791,9 +791,9 @@ discard block |
||
| 791 | 791 | * |
| 792 | 792 | * Does not throw |
| 793 | 793 | */ |
| 794 | - public function getAuthenticatedUser($sessionId="") |
|
| 794 | + public function getAuthenticatedUser($sessionId = "") |
|
| 795 | 795 | { |
| 796 | - if ($sessionId=="") { |
|
| 796 | + if ($sessionId == "") { |
|
| 797 | 797 | $this->logger->debug('Using the PHP session id, as no session id was provided'); |
| 798 | 798 | $sessionId = session_id(); |
| 799 | 799 | } |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | */ |
| 812 | 812 | protected function _getChallengeUrl($sessionKey): string |
| 813 | 813 | { |
| 814 | - $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE . $sessionKey); |
|
| 814 | + $state = $this->_stateStorage->getValue(self::PREFIX_CHALLENGE.$sessionKey); |
|
| 815 | 815 | if (is_null($state)) { |
| 816 | 816 | $this->logger->error( |
| 817 | 817 | sprintf( |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | throw new Exception('Cannot find sessionkey'); |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - $userId = NULL; |
|
| 825 | + $userId = NULL; |
|
| 826 | 826 | $challenge = $state["challenge"]; |
| 827 | 827 | if (isset($state["userId"])) { |
| 828 | 828 | $userId = $state["userId"]; |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | $spIdentifier = $state["spIdentifier"]; |
| 831 | 831 | |
| 832 | 832 | // Last bit is the spIdentifier |
| 833 | - return $this->_protocolAuth."://".(!is_null($userId)?urlencode($userId).'@':'').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion; |
|
| 833 | + return $this->_protocolAuth."://".(!is_null($userId) ?urlencode($userId).'@' : '').$this->getIdentifier()."/".$sessionKey."/".$challenge."/".urlencode($spIdentifier)."/".$this->_protocolVersion; |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | /** |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | protected function _uniqueSessionKey(): string |
| 853 | 853 | { |
| 854 | 854 | |
| 855 | - return bin2hex( Tiqr_Random::randomBytes(self::SESSION_KEY_LENGTH_BYTES) ); |
|
| 855 | + return bin2hex(Tiqr_Random::randomBytes(self::SESSION_KEY_LENGTH_BYTES)); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | * |
| 42 | 42 | * @throws Exception An exception if an unknown user storage is requested. |
| 43 | 43 | */ |
| 44 | - public static function getStorage(string $type="file", array $options=array(), LoggerInterface $logger): Tiqr_UserStorage_Interface |
|
| 44 | + public static function getStorage(string $type = "file", array $options = array(), LoggerInterface $logger): Tiqr_UserStorage_Interface |
|
| 45 | 45 | { |
| 46 | 46 | switch ($type) { |
| 47 | 47 | case "file": |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | * @throws RuntimeException When the options configuration array misses a required parameter |
| 48 | 48 | * |
| 49 | 49 | */ |
| 50 | - public static function getStorage($type="file", $options=array(), LoggerInterface $logger) |
|
| 50 | + public static function getStorage($type = "file", $options = array(), LoggerInterface $logger) |
|
| 51 | 51 | { |
| 52 | 52 | switch ($type) { |
| 53 | 53 | case "file": |