-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add posibility HTTPS without apikey signature #20
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ class Validate | |
* @param array $hosts Set of hostnames (overwrites current) | ||
* @throws \DomainException If curl is not enabled | ||
*/ | ||
public function __construct($apiKey, $clientId, array $hosts = array()) | ||
public function __construct($apiKey = null, $clientId = null, array $hosts = array()) | ||
{ | ||
if ($this->checkCurlSupport() === false) { | ||
throw new \DomainException('cURL support is required and is not enabled!'); | ||
|
@@ -269,7 +269,10 @@ public function check($otp, $multi = false) | |
|
||
$clientId = $this->getClientId(); | ||
if ($clientId === null) { | ||
throw new \InvalidArgumentException('Client ID cannot be null'); | ||
if (!$this->getUseSecure()){ | ||
throw new \InvalidArgumentException('Client ID cannot be null'); | ||
} | ||
$clientId = rand(1,9999); | ||
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. Is it proper to generate the random |
||
} | ||
|
||
$nonce = $this->generateNonce(); | ||
|
@@ -281,7 +284,11 @@ public function check($otp, $multi = false) | |
); | ||
ksort($params); | ||
|
||
$url = '/wsapi/2.0/verify?'.http_build_query($params).'&h='.$this->generateSignature($params); | ||
if (!$this->getUseSecure()){ | ||
$url = '/wsapi/2.0/verify?'.http_build_query($params).'&h='.$this->generateSignature($params); | ||
}else{ | ||
$url = '/wsapi/2.0/verify?'.http_build_query($params); | ||
} | ||
$hosts = ($multi === false) ? array(array_shift($this->hosts)) : $this->hosts; | ||
|
||
return $this->request($url, $hosts, $otp, $nonce); | ||
|
@@ -328,8 +335,10 @@ public function request($url, array $hosts, $otp, $nonce) | |
for ($i = 0; $i < $responseCount; $i++) { | ||
$responses[$i]->setInputOtp($otp)->setInputNonce($nonce); | ||
|
||
if ($this->validateResponseSignature($responses[$i]) === false) { | ||
unset($responses[$i]); | ||
if ($this->getApiKey() and $this->getClientId()){ | ||
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. It should do that as the previous commit mentioned. |
||
if ($this->validateResponseSignature($responses[$i]) === false) { | ||
unset($responses[$i]); | ||
} | ||
} | ||
} | ||
|
||
|
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.
It should have the white space before
{
.