This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Fix validation of IPN response #28
Open
nykopol
wants to merge
9
commits into
lexik:master
Choose a base branch
from
nykopol:validation_repondre_a
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4c18d9c
add validation options and documentation for this options
nykopol 9cec22a
fix error on extension
nykopol 3a0ccf9
modify validation method
nykopol 12098e5
fix error on readme
nykopol 21732fe
fix validation process
nykopol fc9b8f3
fix missing namespace
nykopol 636ae0a
update tests
nykopol f7677a2
Fix forgotten data validation for url_ipn
nykopol 44ab614
Merge remote-tracking branch 'lexik/master' into validation_repondre_a
nykopol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,20 +47,34 @@ class Response | |
*/ | ||
private $publicKey; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $validationBy; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $pbxRetour; | ||
|
||
/** | ||
* Contructor. | ||
* | ||
* @param HttpRequest $request | ||
* @param LoggerInterface $logger | ||
* @param EventDispatcherInterface $dispatcher | ||
* @param string $publicKey | ||
* @param string $validationBy | ||
* @param array $pbxRetour | ||
*/ | ||
public function __construct(HttpRequest $request, LoggerInterface $logger, EventDispatcherInterface $dispatcher, $publicKey) | ||
public function __construct(HttpRequest $request, LoggerInterface $logger, EventDispatcherInterface $dispatcher, $publicKey, $validationBy, array $pbxRetour) | ||
{ | ||
$this->request = $request; | ||
$this->logger = $logger; | ||
$this->dispatcher = $dispatcher; | ||
$this->publicKey = $publicKey; | ||
$this->validationBy = $validationBy; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why creating and injecting a parameter if you don't use it in the class ? |
||
$this->pbxRetour = $pbxRetour; | ||
} | ||
|
||
/** | ||
|
@@ -113,7 +127,7 @@ protected function initData() | |
foreach ($this->getRequestParameters() as $key => $value) { | ||
$this->logger->info(sprintf('%s=%s', $key, $value)); | ||
|
||
if (Paybox::SIGNATURE_PARAMETER !== $key) { | ||
if (in_array($key, $this->pbxRetour)) { | ||
$this->data[$key] = urlencode($value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you use |
||
} | ||
} | ||
|
@@ -131,10 +145,7 @@ public function verifySignature() | |
$this->initData(); | ||
$this->initSignature(); | ||
|
||
$file = fopen($this->publicKey, 'r'); | ||
$cert = fread($file, 8192); | ||
fclose($file); | ||
|
||
$cert = file_get_contents($this->publicKey); | ||
$publicKey = openssl_get_publickey($cert); | ||
|
||
$result = openssl_verify( | ||
|
@@ -163,4 +174,5 @@ public function verifySignature() | |
|
||
return $result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should set the parameter with an empty array or you will get a warning when in_array() is called in Response on line 130:
if (in_array($key, $this->pbxRetour)) {