Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/Yubikey/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
Expand Down Expand Up @@ -269,7 +269,9 @@ public function check($otp, $multi = false)

$clientId = $this->getClientId();
if ($clientId === null) {
throw new \InvalidArgumentException('Client ID cannot be null');
if (!$this->getUseSecure())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the { and } on this for consistency?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you want, :).

On 18/03/16 12:30, Chris Cornutt wrote:

In src/Yubikey/Validate.php
#20 (comment):

@@ -269,7 +269,9 @@ public function check($otp, $multi = false)

     $clientId = $this->getClientId();
     if ($clientId === null) {
  •        throw new \InvalidArgumentException('Client ID cannot be null');
    
  •        if (!$this->getUseSecure())
    

Can you add the |{| and |}| on this for consistency?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/enygma/yubikey/pull/20/files/67816d0b4177845c29a2370c7aa62fc3fbc95997#r56643355

throw new \InvalidArgumentException('Client ID cannot be null');
$clientId = 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think refactoring things a bit here to just not add the clientId value to the $params array might be a better way to handle this than hard-coding an ID like this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the clientId is required to do the request. If you want put more
beautiful, you could put random integer (0-9999).
https://demo.yubico.com/php-yubico/demo.php

On 18/03/16 12:32, Chris Cornutt wrote:

In src/Yubikey/Validate.php
#20 (comment):

@@ -269,7 +269,9 @@ 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 = 1;
    

I think refactoring things a bit here to just not add the |clientId|
value to the |$params| array might be a better way to handle this than
hard-coding an ID like this.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/enygma/yubikey/pull/20/files/67816d0b4177845c29a2370c7aa62fc3fbc95997#r56643547

}

$nonce = $this->generateNonce();
Expand All @@ -281,7 +283,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);
Expand Down Expand Up @@ -328,8 +334,9 @@ 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())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity can you add the opening { here?

if ($this->validateResponseSignature($responses[$i]) === false) {
unset($responses[$i]);
}
}

Expand Down