@@ -54,8 +54,8 @@ |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $envelope = array("expire"=>$expire, |
| 57 | - "createdAt"=>time(), |
|
| 58 | - "value"=>$value); |
|
| 57 | + "createdAt"=>time(), |
|
| 58 | + "value"=>$value); |
|
| 59 | 59 | $filename = $this->getFilenameByKey($key); |
| 60 | 60 | |
| 61 | 61 | if (!file_put_contents($filename, serialize($envelope))) { |
@@ -21,7 +21,6 @@ |
||
| 21 | 21 | * |
| 22 | 22 | * |
| 23 | 23 | * Create SQL table (MySQL): |
| 24 | - |
|
| 25 | 24 | * CREATE TABLE IF NOT EXISTS tiqrstate ( |
| 26 | 25 | key varchar(255) PRIMARY KEY, |
| 27 | 26 | expire BIGINT, |
@@ -584,17 +584,17 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | $metadata = array("service"=> |
| 587 | - array("displayName" => $this->_name, |
|
| 588 | - "identifier" => $this->_identifier, |
|
| 589 | - "logoUrl" => $this->_logoUrl, |
|
| 590 | - "infoUrl" => $this->_infoUrl, |
|
| 591 | - "authenticationUrl" => $authenticationUrl, |
|
| 592 | - "ocraSuite" => $this->_ocraSuite, |
|
| 593 | - "enrollmentUrl" => $enrollmentUrl |
|
| 594 | - ), |
|
| 595 | - "identity"=> |
|
| 596 | - array("identifier" =>$data["userId"], |
|
| 597 | - "displayName"=>$data["displayName"])); |
|
| 587 | + array("displayName" => $this->_name, |
|
| 588 | + "identifier" => $this->_identifier, |
|
| 589 | + "logoUrl" => $this->_logoUrl, |
|
| 590 | + "infoUrl" => $this->_infoUrl, |
|
| 591 | + "authenticationUrl" => $authenticationUrl, |
|
| 592 | + "ocraSuite" => $this->_ocraSuite, |
|
| 593 | + "enrollmentUrl" => $enrollmentUrl |
|
| 594 | + ), |
|
| 595 | + "identity"=> |
|
| 596 | + array("identifier" =>$data["userId"], |
|
| 597 | + "displayName"=>$data["displayName"])); |
|
| 598 | 598 | |
| 599 | 599 | $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
| 600 | 600 | |
@@ -618,18 +618,18 @@ discard block |
||
| 618 | 618 | */ |
| 619 | 619 | public function getEnrollmentSecret(string $enrollmentKey): string |
| 620 | 620 | { |
| 621 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 622 | - $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
|
| 623 | - $enrollmentData = [ |
|
| 624 | - "userId" => $data["userId"], |
|
| 625 | - "sessionId" => $data["sessionId"] |
|
| 626 | - ]; |
|
| 627 | - $this->_stateStorage->setValue( |
|
| 628 | - self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
| 629 | - $enrollmentData, |
|
| 630 | - self::ENROLLMENT_EXPIRE |
|
| 631 | - ); |
|
| 632 | - return $secret; |
|
| 621 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
| 622 | + $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
|
| 623 | + $enrollmentData = [ |
|
| 624 | + "userId" => $data["userId"], |
|
| 625 | + "sessionId" => $data["sessionId"] |
|
| 626 | + ]; |
|
| 627 | + $this->_stateStorage->setValue( |
|
| 628 | + self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
| 629 | + $enrollmentData, |
|
| 630 | + self::ENROLLMENT_EXPIRE |
|
| 631 | + ); |
|
| 632 | + return $secret; |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
@@ -668,18 +668,18 @@ discard block |
||
| 668 | 668 | */ |
| 669 | 669 | public function finalizeEnrollment($enrollmentSecret) |
| 670 | 670 | { |
| 671 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 672 | - if (is_array($data)) { |
|
| 673 | - // Enrollment is finalized, destroy our session data. |
|
| 674 | - $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED); |
|
| 675 | - $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 676 | - } else { |
|
| 677 | - $this->logger->error( |
|
| 678 | - 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
| 679 | - 'Warning! the method will still return "true" as a result.' |
|
| 680 | - ); |
|
| 681 | - } |
|
| 682 | - return true; |
|
| 671 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 672 | + if (is_array($data)) { |
|
| 673 | + // Enrollment is finalized, destroy our session data. |
|
| 674 | + $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED); |
|
| 675 | + $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
| 676 | + } else { |
|
| 677 | + $this->logger->error( |
|
| 678 | + 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
| 679 | + 'Warning! the method will still return "true" as a result.' |
|
| 680 | + ); |
|
| 681 | + } |
|
| 682 | + return true; |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | /** |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | |
| 717 | 717 | $challengeUserId = NULL; |
| 718 | 718 | if (isset($state["userId"])) { |
| 719 | - $challengeUserId = $state["userId"]; |
|
| 719 | + $challengeUserId = $state["userId"]; |
|
| 720 | 720 | } |
| 721 | 721 | // Check if we're dealing with a second factor |
| 722 | 722 | if ($challengeUserId!=NULL && ($userId != $challengeUserId)) { |
@@ -864,6 +864,6 @@ discard block |
||
| 864 | 864 | */ |
| 865 | 865 | protected function _setEnrollmentStatus($sessionId, $status) |
| 866 | 866 | { |
| 867 | - $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE); |
|
| 867 | + $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE); |
|
| 868 | 868 | } |
| 869 | 869 | } |