-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from graze/v0.2
V0.2
- Loading branch information
Showing
57 changed files
with
2,789 additions
and
1,536 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/vendor/ | ||
composer.lock | ||
/tests/report/ |
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Graze\Gigya\Auth; | ||
|
||
use GuzzleHttp\Event\SubscriberInterface; | ||
|
||
interface GigyaAuthInterface extends SubscriberInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getApiKey(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSecret(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUserKey(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace Graze\Gigya\Auth; | ||
|
||
use GuzzleHttp\Event\BeforeEvent; | ||
use GuzzleHttp\Event\RequestEvents; | ||
|
||
class GigyaHttpsAuth implements GigyaAuthInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $apiKey; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $secret; | ||
|
||
/** | ||
* @var null|string | ||
*/ | ||
private $userKey; | ||
|
||
/** | ||
* @param string $apiKey | ||
* @param string $secret | ||
* @param string|null $userKey | ||
*/ | ||
public function __construct($apiKey, $secret, $userKey = null) | ||
{ | ||
$this->apiKey = $apiKey; | ||
$this->secret = $secret; | ||
$this->userKey = $userKey; | ||
} | ||
|
||
/** | ||
* Returns an array of event names this subscriber wants to listen to. | ||
* | ||
* @return array | ||
*/ | ||
public function getEvents() | ||
{ | ||
return ['before' => ['sign', RequestEvents::SIGN_REQUEST]]; | ||
} | ||
|
||
/** | ||
* Add the authentication params to the request. | ||
* | ||
* @param BeforeEvent $event | ||
*/ | ||
public function sign(BeforeEvent $event) | ||
{ | ||
$request = $event->getRequest(); | ||
if ($request->getScheme() == 'https' && $request->getConfig()->get('auth') == 'gigya') { | ||
$query = $request->getQuery(); | ||
$query['apiKey'] = $this->apiKey; | ||
$query['secret'] = $this->secret; | ||
if ($this->userKey) { | ||
$query['userKey'] = $this->userKey; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getApiKey() | ||
{ | ||
return $this->apiKey; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSecret() | ||
{ | ||
return $this->secret; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUserKey() | ||
{ | ||
return $this->userKey; | ||
} | ||
} |
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
Oops, something went wrong.