@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | public function setValue($key, $value, $expire=0) |
40 | 40 | { |
41 | 41 | $envelope = array("expire"=>$expire, |
42 | - "createdAt"=>time(), |
|
43 | - "value"=>$value); |
|
42 | + "createdAt"=>time(), |
|
43 | + "value"=>$value); |
|
44 | 44 | $filename = $this->_stateFilename($key); |
45 | 45 | |
46 | 46 | file_put_contents($filename, serialize($envelope)); |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | if (file_exists($filename)) { |
73 | 73 | $envelope = unserialize(file_get_contents($filename)); |
74 | 74 | if ($envelope["expire"]!=0) { |
75 | - // This data is time-limited. If it's too old we discard it. |
|
76 | - if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
77 | - $this->unsetValue($key); |
|
78 | - $this->logger->error('Unable to retrieve the state storage value, it is expired'); |
|
79 | - return NULL; |
|
80 | - } |
|
75 | + // This data is time-limited. If it's too old we discard it. |
|
76 | + if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
77 | + $this->unsetValue($key); |
|
78 | + $this->logger->error('Unable to retrieve the state storage value, it is expired'); |
|
79 | + return NULL; |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | return $envelope["value"]; |
83 | 83 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public function createUser($userId, $displayName) |
44 | 44 | { |
45 | 45 | $user = array("userId"=>$userId, |
46 | - "displayName"=>$displayName); |
|
46 | + "displayName"=>$displayName); |
|
47 | 47 | return $this->_saveUser($userId, $user); |
48 | 48 | } |
49 | 49 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | if ($data = $this->_loadUser($userId)) { |
79 | 79 | if (isset($data["notificationType"])) { |
80 | - return $data["notificationType"]; |
|
80 | + return $data["notificationType"]; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | return NULL; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | if ($data = $this->_loadUser($userId)) { |
104 | 104 | if (isset($data["notificationAddress"])) { |
105 | - return $data["notificationAddress"]; |
|
105 | + return $data["notificationAddress"]; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | $this->logger->info('Unable to find notification address for user'); |
@@ -552,17 +552,17 @@ discard block |
||
552 | 552 | } |
553 | 553 | |
554 | 554 | $metadata = array("service"=> |
555 | - array("displayName" => $this->_name, |
|
556 | - "identifier" => $this->_identifier, |
|
557 | - "logoUrl" => $this->_logoUrl, |
|
558 | - "infoUrl" => $this->_infoUrl, |
|
559 | - "authenticationUrl" => $authenticationUrl, |
|
560 | - "ocraSuite" => $this->_ocraSuite, |
|
561 | - "enrollmentUrl" => $enrollmentUrl |
|
562 | - ), |
|
563 | - "identity"=> |
|
564 | - array("identifier" =>$data["userId"], |
|
565 | - "displayName"=>$data["displayName"])); |
|
555 | + array("displayName" => $this->_name, |
|
556 | + "identifier" => $this->_identifier, |
|
557 | + "logoUrl" => $this->_logoUrl, |
|
558 | + "infoUrl" => $this->_infoUrl, |
|
559 | + "authenticationUrl" => $authenticationUrl, |
|
560 | + "ocraSuite" => $this->_ocraSuite, |
|
561 | + "enrollmentUrl" => $enrollmentUrl |
|
562 | + ), |
|
563 | + "identity"=> |
|
564 | + array("identifier" =>$data["userId"], |
|
565 | + "displayName"=>$data["displayName"])); |
|
566 | 566 | |
567 | 567 | $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
568 | 568 | |
@@ -585,18 +585,18 @@ discard block |
||
585 | 585 | */ |
586 | 586 | public function getEnrollmentSecret($enrollmentKey) |
587 | 587 | { |
588 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
589 | - $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
|
590 | - $enrollmentData = [ |
|
591 | - "userId" => $data["userId"], |
|
592 | - "sessionId" => $data["sessionId"] |
|
593 | - ]; |
|
594 | - $this->_stateStorage->setValue( |
|
595 | - self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
596 | - $enrollmentData, |
|
597 | - self::ENROLLMENT_EXPIRE |
|
598 | - ); |
|
599 | - return $secret; |
|
588 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT . $enrollmentKey); |
|
589 | + $secret = $this->_uniqueSessionKey(self::PREFIX_ENROLLMENT_SECRET); |
|
590 | + $enrollmentData = [ |
|
591 | + "userId" => $data["userId"], |
|
592 | + "sessionId" => $data["sessionId"] |
|
593 | + ]; |
|
594 | + $this->_stateStorage->setValue( |
|
595 | + self::PREFIX_ENROLLMENT_SECRET . $secret, |
|
596 | + $enrollmentData, |
|
597 | + self::ENROLLMENT_EXPIRE |
|
598 | + ); |
|
599 | + return $secret; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -635,18 +635,18 @@ discard block |
||
635 | 635 | */ |
636 | 636 | public function finalizeEnrollment($enrollmentSecret) |
637 | 637 | { |
638 | - $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
639 | - if (is_array($data)) { |
|
640 | - // Enrollment is finalized, destroy our session data. |
|
641 | - $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED); |
|
642 | - $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
643 | - } else { |
|
644 | - $this->logger->error( |
|
645 | - 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
646 | - 'Warning! the method will still return "true" as a result.' |
|
647 | - ); |
|
648 | - } |
|
649 | - return true; |
|
638 | + $data = $this->_stateStorage->getValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
639 | + if (is_array($data)) { |
|
640 | + // Enrollment is finalized, destroy our session data. |
|
641 | + $this->_setEnrollmentStatus($data["sessionId"], self::ENROLLMENT_STATUS_FINALIZED); |
|
642 | + $this->_stateStorage->unsetValue(self::PREFIX_ENROLLMENT_SECRET.$enrollmentSecret); |
|
643 | + } else { |
|
644 | + $this->logger->error( |
|
645 | + 'Enrollment status is not finalized, enrollmentsecret was not found in state storage. ' . |
|
646 | + 'Warning! the method will still return "true" as a result.' |
|
647 | + ); |
|
648 | + } |
|
649 | + return true; |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | /** |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | |
684 | 684 | $challengeUserId = NULL; |
685 | 685 | if (isset($state["userId"])) { |
686 | - $challengeUserId = $state["userId"]; |
|
686 | + $challengeUserId = $state["userId"]; |
|
687 | 687 | } |
688 | 688 | // Check if we're dealing with a second factor |
689 | 689 | if ($challengeUserId!=NULL && ($userId != $challengeUserId)) { |
@@ -830,6 +830,6 @@ discard block |
||
830 | 830 | */ |
831 | 831 | protected function _setEnrollmentStatus($sessionId, $status) |
832 | 832 | { |
833 | - $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE); |
|
833 | + $this->_stateStorage->setValue("enrollstatus".$sessionId, $status, self::ENROLLMENT_EXPIRE); |
|
834 | 834 | } |
835 | 835 | } |