summaryrefslogtreecommitdiff
path: root/vendor/OAuth
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-09 07:21:10 +0200
committerFrédéric Guillot <fred@kanboard.net>2014-09-09 07:21:10 +0200
commit54a77cd58589e8c73543360af1469151fb1a550c (patch)
tree86ab929a2981a8147656c2e6119c7f1e0e130c3e /vendor/OAuth
parent0d4b6525dd86f837eb9e931e48a92fc6a0033e11 (diff)
Update dependencies
Diffstat (limited to 'vendor/OAuth')
-rwxr-xr-xvendor/OAuth/Common/Token/AbstractToken.php7
-rwxr-xr-xvendor/OAuth/OAuth1/Service/AbstractService.php10
-rwxr-xr-xvendor/OAuth/OAuth1/Service/Etsy.php38
-rw-r--r--vendor/OAuth/OAuth2/Service/Buffer.php151
-rwxr-xr-xvendor/OAuth/OAuth2/Service/GitHub.php43
-rwxr-xr-xvendor/OAuth/OAuth2/Service/Google.php10
-rwxr-xr-xvendor/OAuth/OAuth2/Service/Harvest.php84
-rwxr-xr-xvendor/OAuth/OAuth2/Service/Salesforce.php2
-rw-r--r--vendor/OAuth/OAuth2/Service/Ustream.php98
-rwxr-xr-xvendor/OAuth/OAuth2/Service/Vkontakte.php1
10 files changed, 423 insertions, 21 deletions
diff --git a/vendor/OAuth/Common/Token/AbstractToken.php b/vendor/OAuth/Common/Token/AbstractToken.php
index 8d448a18..7a362473 100755
--- a/vendor/OAuth/Common/Token/AbstractToken.php
+++ b/vendor/OAuth/Common/Token/AbstractToken.php
@@ -118,4 +118,11 @@ abstract class AbstractToken implements TokenInterface
{
$this->refreshToken = $refreshToken;
}
+
+ public function isExpired()
+ {
+ return ($this->getEndOfLife() !== TokenInterface::EOL_NEVER_EXPIRES
+ && $this->getEndOfLife() !== TokenInterface::EOL_UNKNOWN
+ && time() > $this->getEndOfLife());
+ }
}
diff --git a/vendor/OAuth/OAuth1/Service/AbstractService.php b/vendor/OAuth/OAuth1/Service/AbstractService.php
index 0bff5558..43c9c9f6 100755
--- a/vendor/OAuth/OAuth1/Service/AbstractService.php
+++ b/vendor/OAuth/OAuth1/Service/AbstractService.php
@@ -82,10 +82,6 @@ abstract class AbstractService extends BaseAbstractService implements ServiceInt
}
$this->signature->setTokenSecret($tokenSecret);
- $extraAuthenticationHeaders = array(
- 'oauth_token' => $token,
- );
-
$bodyParams = array(
'oauth_verifier' => $verifier,
);
@@ -207,10 +203,8 @@ abstract class AbstractService extends BaseAbstractService implements ServiceInt
}
$parameters = array_merge($parameters, array('oauth_token' => $token->getAccessToken()));
-
- $mergedParams = (is_array($bodyParams)) ? array_merge($parameters, $bodyParams) : $parameters;
-
- $parameters['oauth_signature'] = $this->signature->getSignature($uri, $mergedParams, $method);
+ $parameters = (is_array($bodyParams)) ? array_merge($parameters, $bodyParams) : $parameters;
+ $parameters['oauth_signature'] = $this->signature->getSignature($uri, $parameters, $method);
$authorizationHeader = 'OAuth ';
$delimiter = '';
diff --git a/vendor/OAuth/OAuth1/Service/Etsy.php b/vendor/OAuth/OAuth1/Service/Etsy.php
index 884358eb..30dc331c 100755
--- a/vendor/OAuth/OAuth1/Service/Etsy.php
+++ b/vendor/OAuth/OAuth1/Service/Etsy.php
@@ -13,6 +13,9 @@ use OAuth\Common\Http\Client\ClientInterface;
class Etsy extends AbstractService
{
+
+ protected $scopes = array();
+
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
@@ -32,7 +35,14 @@ class Etsy extends AbstractService
*/
public function getRequestTokenEndpoint()
{
- return new Uri($this->baseApiUri . 'oauth/request_token');
+ $uri = new Uri($this->baseApiUri . 'oauth/request_token');
+ $scopes = $this->getScopes();
+
+ if (count($scopes)) {
+ $uri->setQuery('scope=' . implode('%20', $scopes));
+ }
+
+ return $uri;
}
/**
@@ -93,4 +103,30 @@ class Etsy extends AbstractService
return $token;
}
+
+ /**
+ * Set the scopes for permissions
+ * @see https://www.etsy.com/developers/documentation/getting_started/oauth#section_permission_scopes
+ * @param array $scopes
+ *
+ * @return $this
+ */
+ public function setScopes(array $scopes)
+ {
+ if (!is_array($scopes)) {
+ $scopes = array();
+ }
+
+ $this->scopes = $scopes;
+ return $this;
+ }
+
+ /**
+ * Return the defined scopes
+ * @return array
+ */
+ public function getScopes()
+ {
+ return $this->scopes;
+ }
}
diff --git a/vendor/OAuth/OAuth2/Service/Buffer.php b/vendor/OAuth/OAuth2/Service/Buffer.php
new file mode 100644
index 00000000..5905678e
--- /dev/null
+++ b/vendor/OAuth/OAuth2/Service/Buffer.php
@@ -0,0 +1,151 @@
+<?php
+
+namespace OAuth\OAuth2\Service;
+
+use OAuth\OAuth2\Token\StdOAuth2Token;
+use OAuth\Common\Http\Exception\TokenResponseException;
+use OAuth\Common\Http\Uri\Uri;
+use OAuth\Common\Consumer\CredentialsInterface;
+use OAuth\Common\Http\Uri\UriInterface;
+use OAuth\Common\Storage\TokenStorageInterface;
+use OAuth\Common\Http\Client\ClientInterface;
+
+/**
+ * Buffer API.
+ * @author Sumukh Sridhara <@sumukhsridhara>
+ * @link https://bufferapp.com/developers/api
+ */
+class Buffer extends AbstractService
+{
+ public function __construct(
+ CredentialsInterface $credentials,
+ ClientInterface $httpClient,
+ TokenStorageInterface $storage,
+ $scopes = array(),
+ UriInterface $baseApiUri = null
+ ) {
+ parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
+ if ($baseApiUri === null) {
+ $this->baseApiUri = new Uri('https://api.bufferapp.com/1/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://bufferapp.com/oauth2/authorize');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://api.bufferapp.com/1/oauth2/token.json');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getAuthorizationMethod()
+ {
+ return static::AUTHORIZATION_METHOD_QUERY_STRING;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationUri(array $additionalParameters = array())
+ {
+ $parameters = array_merge(
+ $additionalParameters,
+ array(
+ 'client_id' => $this->credentials->getConsumerId(),
+ 'redirect_uri' => $this->credentials->getCallbackUrl(),
+ 'response_type' => 'code',
+ )
+ );
+
+ // Build the url
+ $url = clone $this->getAuthorizationEndpoint();
+ foreach ($parameters as $key => $val) {
+ $url->addToQuery($key, $val);
+ }
+
+ return $url;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function requestRequestToken()
+ {
+ $responseBody = $this->httpClient->retrieveResponse(
+ $this->getRequestTokenEndpoint(),
+ array(
+ 'client_key' => $this->credentials->getConsumerId(),
+ 'redirect_uri' => $this->credentials->getCallbackUrl(),
+ 'response_type' => 'code',
+ )
+ );
+
+ $code = $this->parseRequestTokenResponse($responseBody);
+
+ return $code;
+ }
+
+ protected function parseRequestTokenResponse($responseBody)
+ {
+ parse_str($responseBody, $data);
+
+ if (null === $data || !is_array($data)) {
+ throw new TokenResponseException('Unable to parse response.');
+ } elseif (!isset($data['code'])) {
+ throw new TokenResponseException('Error in retrieving code.');
+ }
+ return $data['code'];
+ }
+
+ public function requestAccessToken($code)
+ {
+ $bodyParams = array(
+ 'client_id' => $this->credentials->getConsumerId(),
+ 'client_secret' => $this->credentials->getConsumerSecret(),
+ 'redirect_uri' => $this->credentials->getCallbackUrl(),
+ 'code' => $code,
+ 'grant_type' => 'authorization_code',
+ );
+
+ $responseBody = $this->httpClient->retrieveResponse(
+ $this->getAccessTokenEndpoint(),
+ $bodyParams,
+ $this->getExtraOAuthHeaders()
+ );
+ $token = $this->parseAccessTokenResponse($responseBody);
+ $this->storage->storeAccessToken($this->service(), $token);
+
+ return $token;
+ }
+
+ protected function parseAccessTokenResponse($responseBody)
+ {
+ $data = json_decode($responseBody, true);
+
+ if ($data === null || !is_array($data)) {
+ throw new TokenResponseException('Unable to parse response.');
+ } elseif (isset($data['error'])) {
+ throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
+ }
+
+ $token = new StdOAuth2Token();
+ $token->setAccessToken($data['access_token']);
+
+ $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
+ unset($data['access_token']);
+ $token->setExtraParams($data);
+
+ return $token;
+ }
+}
diff --git a/vendor/OAuth/OAuth2/Service/GitHub.php b/vendor/OAuth/OAuth2/Service/GitHub.php
index 3791a275..9fee2ba0 100755
--- a/vendor/OAuth/OAuth2/Service/GitHub.php
+++ b/vendor/OAuth/OAuth2/Service/GitHub.php
@@ -51,6 +51,13 @@ class GitHub extends AbstractService
const SCOPE_REPO = 'repo';
/**
+ * Grants access to deployment statuses for public and private repositories.
+ * This scope is only necessary to grant other users or services access to deployment statuses,
+ * without granting access to the code.
+ */
+ const SCOPE_REPO_DEPLOYMENT = 'repo_deployment';
+
+ /**
* Read/write access to public and private repository commit statuses. This scope is only necessary to grant other
* users or services access to private repository commit statuses without granting access to the code. The repo and
* public_repo scopes already include access to commit status for private and public repositories, respectively.
@@ -71,22 +78,52 @@ class GitHub extends AbstractService
* Write access to gists.
*/
const SCOPE_GIST = 'gist';
-
+
/**
* Grants read and ping access to hooks in public or private repositories.
*/
const SCOPE_HOOKS_READ = 'read:repo_hook';
-
+
/**
* Grants read, write, and ping access to hooks in public or private repositories.
*/
const SCOPE_HOOKS_WRITE = 'write:repo_hook';
-
+
/**
* Grants read, write, ping, and delete access to hooks in public or private repositories.
*/
const SCOPE_HOOKS_ADMIN = 'admin:repo_hook';
+ /**
+ * Read-only access to organization, teams, and membership.
+ */
+ const SCOPE_ORG_READ = 'read:org';
+
+ /**
+ * Publicize and unpublicize organization membership.
+ */
+ const SCOPE_ORG_WRITE = 'write:org';
+
+ /**
+ * Fully manage organization, teams, and memberships.
+ */
+ const SCOPE_ORG_ADMIN = 'admin:org';
+
+ /**
+ * List and view details for public keys.
+ */
+ const SCOPE_PUBLIC_KEY_READ = 'read:public_key';
+
+ /**
+ * Create, list, and view details for public keys.
+ */
+ const SCOPE_PUBLIC_KEY_WRITE = 'write:public_key';
+
+ /**
+ * Fully manage public keys.
+ */
+ const SCOPE_PUBLIC_KEY_ADMIN = 'admin:public_key';
+
public function __construct(
CredentialsInterface $credentials,
ClientInterface $httpClient,
diff --git a/vendor/OAuth/OAuth2/Service/Google.php b/vendor/OAuth/OAuth2/Service/Google.php
index fbfc1f29..096876b6 100755
--- a/vendor/OAuth/OAuth2/Service/Google.php
+++ b/vendor/OAuth/OAuth2/Service/Google.php
@@ -26,6 +26,11 @@ class Google extends AbstractService
// Google+
const SCOPE_GPLUS_ME = 'https://www.googleapis.com/auth/plus.me';
const SCOPE_GPLUS_LOGIN = 'https://www.googleapis.com/auth/plus.login';
+ const SCOPE_GPLUS_CIRCLES_READ = 'https://www.googleapis.com/auth/plus.circles.read';
+ const SCOPE_GPLUS_CIRCLES_WRITE = 'https://www.googleapis.com/auth/plus.circles.write';
+ const SCOPE_GPLUS_STREAM_READ = 'https://www.googleapis.com/auth/plus.stream.read';
+ const SCOPE_GPLUS_STREAM_WRITE = 'https://www.googleapis.com/auth/plus.stream.write';
+ const SCOPE_GPLUS_MEDIA = 'https://www.googleapis.com/auth/plus.media.upload';
// Google Drive
const SCOPE_DOCUMENTSLIST = 'https://docs.google.com/feeds/';
@@ -57,6 +62,7 @@ class Google extends AbstractService
const SCOPE_CONTACT = 'https://www.google.com/m8/feeds/';
const SCOPE_CHROMEWEBSTORE = 'https://www.googleapis.com/auth/chromewebstore.readonly';
const SCOPE_GMAIL = 'https://mail.google.com/mail/feed/atom';
+ const SCOPE_GMAIL_IMAP_SMTP = 'https://mail.google.com';
const SCOPE_PICASAWEB = 'https://picasaweb.google.com/data/';
const SCOPE_SITES = 'https://sites.google.com/feeds/';
const SCOPE_URLSHORTENER = 'https://www.googleapis.com/auth/urlshortener';
@@ -83,8 +89,8 @@ class Google extends AbstractService
const SCOPE_YOUTUBE = 'https://www.googleapis.com/auth/youtube';
const SCOPE_YOUTUBE_READ_ONLY = 'https://www.googleapis.com/auth/youtube.readonly';
const SCOPE_YOUTUBE_UPLOAD = 'https://www.googleapis.com/auth/youtube.upload';
- const SCOPE_YOUTUBE_PATNER = 'https://www.googleapis.com/auth/youtubepartner';
- const SCOPE_YOUTUBE_PARTNER_EDIT = 'https://www.googleapis.com/auth/youtubepartner-channel-edit';
+ const SCOPE_YOUTUBE_PARTNER = 'https://www.googleapis.com/auth/youtubepartner';
+ const SCOPE_YOUTUBE_PARTNER_AUDIT = 'https://www.googleapis.com/auth/youtubepartner-channel-audit';
// Google Glass
const SCOPE_GLASS_TIMELINE = 'https://www.googleapis.com/auth/glass.timeline';
diff --git a/vendor/OAuth/OAuth2/Service/Harvest.php b/vendor/OAuth/OAuth2/Service/Harvest.php
index 86e8993c..96fb0f2d 100755
--- a/vendor/OAuth/OAuth2/Service/Harvest.php
+++ b/vendor/OAuth/OAuth2/Service/Harvest.php
@@ -2,13 +2,14 @@
namespace OAuth\OAuth2\Service;
-use OAuth\OAuth2\Token\StdOAuth2Token;
-use OAuth\Common\Http\Exception\TokenResponseException;
-use OAuth\Common\Http\Uri\Uri;
use OAuth\Common\Consumer\CredentialsInterface;
use OAuth\Common\Http\Client\ClientInterface;
-use OAuth\Common\Storage\TokenStorageInterface;
+use OAuth\Common\Http\Exception\TokenResponseException;
+use OAuth\Common\Http\Uri\Uri;
use OAuth\Common\Http\Uri\UriInterface;
+use OAuth\Common\Storage\TokenStorageInterface;
+use OAuth\Common\Token\TokenInterface;
+use OAuth\OAuth2\Token\StdOAuth2Token;
class Harvest extends AbstractService
{
@@ -23,8 +24,32 @@ class Harvest extends AbstractService
parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
if (null === $baseApiUri) {
- $this->baseApiUri = new Uri('https://api.github.com/');
+ $this->baseApiUri = new Uri('https://api.harvestapp.com/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationUri(array $additionalParameters = array())
+ {
+ $parameters = array_merge(
+ $additionalParameters,
+ array(
+ 'client_id' => $this->credentials->getConsumerId(),
+ 'redirect_uri' => $this->credentials->getCallbackUrl(),
+ 'state' => 'optional-csrf-token',
+ 'response_type' => 'code',
+ )
+ );
+
+ // Build the url
+ $url = clone $this->getAuthorizationEndpoint();
+ foreach ($parameters as $key => $val) {
+ $url->addToQuery($key, $val);
}
+
+ return $url;
}
/**
@@ -66,7 +91,8 @@ class Harvest extends AbstractService
$token = new StdOAuth2Token();
$token->setAccessToken($data['access_token']);
- $token->setEndOfLife($data['expires_in']);
+ $token->setLifetime($data['expires_in']);
+ $token->setRefreshToken($data['refresh_token']);
unset($data['access_token']);
@@ -76,10 +102,56 @@ class Harvest extends AbstractService
}
/**
+ * Refreshes an OAuth2 access token.
+ *
+ * @param TokenInterface $token
+ *
+ * @return TokenInterface $token
+ *
+ * @throws MissingRefreshTokenException
+ */
+ public function refreshAccessToken(TokenInterface $token)
+ {
+ $refreshToken = $token->getRefreshToken();
+
+ if (empty($refreshToken)) {
+ throw new MissingRefreshTokenException();
+ }
+
+ $parameters = array(
+ 'grant_type' => 'refresh_token',
+ 'type' => 'web_server',
+ 'client_id' => $this->credentials->getConsumerId(),
+ 'client_secret' => $this->credentials->getConsumerSecret(),
+ 'refresh_token' => $refreshToken,
+ );
+
+ $responseBody = $this->httpClient->retrieveResponse(
+ $this->getAccessTokenEndpoint(),
+ $parameters,
+ $this->getExtraOAuthHeaders()
+ );
+ $token = $this->parseAccessTokenResponse($responseBody);
+ $this->storage->storeAccessToken($this->service(), $token);
+
+ return $token;
+ }
+
+ /**
* @return array
*/
protected function getExtraOAuthHeaders()
{
return array('Accept' => 'application/json');
}
+
+ /**
+ * Return any additional headers always needed for this service implementation's API calls.
+ *
+ * @return array
+ */
+ protected function getExtraApiHeaders()
+ {
+ return array('Accept' => 'application/json');
+ }
}
diff --git a/vendor/OAuth/OAuth2/Service/Salesforce.php b/vendor/OAuth/OAuth2/Service/Salesforce.php
index 7d74db9d..583e4347 100755
--- a/vendor/OAuth/OAuth2/Service/Salesforce.php
+++ b/vendor/OAuth/OAuth2/Service/Salesforce.php
@@ -1,6 +1,6 @@
<?php
-namespace OAuth\Common\Service;
+namespace OAuth\OAuth2\Service;
use OAuth\OAuth2\Service\AbstractService;
use OAuth\OAuth2\Token\StdOAuth2Token;
diff --git a/vendor/OAuth/OAuth2/Service/Ustream.php b/vendor/OAuth/OAuth2/Service/Ustream.php
new file mode 100644
index 00000000..7e558153
--- /dev/null
+++ b/vendor/OAuth/OAuth2/Service/Ustream.php
@@ -0,0 +1,98 @@
+<?php
+
+namespace OAuth\OAuth2\Service;
+
+use OAuth\OAuth2\Token\StdOAuth2Token;
+use OAuth\Common\Http\Exception\TokenResponseException;
+use OAuth\Common\Http\Uri\Uri;
+use OAuth\Common\Consumer\CredentialsInterface;
+use OAuth\Common\Http\Client\ClientInterface;
+use OAuth\Common\Storage\TokenStorageInterface;
+use OAuth\Common\Http\Uri\UriInterface;
+
+class Ustream extends AbstractService
+{
+ /**
+ * Scopes
+ *
+ * @var string
+ */
+ const SCOPE_OFFLINE = 'offline';
+ const SCOPE_BROADCASTER = 'broadcaster';
+
+ public function __construct(
+ CredentialsInterface $credentials,
+ ClientInterface $httpClient,
+ TokenStorageInterface $storage,
+ $scopes = array(),
+ UriInterface $baseApiUri = null
+ ) {
+ parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri, true);
+
+ if (null === $baseApiUri) {
+ $this->baseApiUri = new Uri('https://api.ustream.tv/');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAuthorizationEndpoint()
+ {
+ return new Uri('https://www.ustream.tv/oauth2/authorize');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAccessTokenEndpoint()
+ {
+ return new Uri('https://www.ustream.tv/oauth2/token');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getAuthorizationMethod()
+ {
+ return static::AUTHORIZATION_METHOD_HEADER_BEARER;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function parseAccessTokenResponse($responseBody)
+ {
+ $data = json_decode($responseBody, true);
+
+ if (null === $data || !is_array($data)) {
+ throw new TokenResponseException('Unable to parse response.');
+ } elseif (isset($data['error'])) {
+ throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
+ }
+
+ $token = new StdOAuth2Token();
+ $token->setAccessToken($data['access_token']);
+ $token->setLifeTime($data['expires_in']);
+
+ if (isset($data['refresh_token'])) {
+ $token->setRefreshToken($data['refresh_token']);
+ unset($data['refresh_token']);
+ }
+
+ unset($data['access_token']);
+ unset($data['expires_in']);
+
+ $token->setExtraParams($data);
+
+ return $token;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExtraOAuthHeaders()
+ {
+ return array('Authorization' => 'Basic ' . $this->credentials->getConsumerSecret());
+ }
+}
diff --git a/vendor/OAuth/OAuth2/Service/Vkontakte.php b/vendor/OAuth/OAuth2/Service/Vkontakte.php
index ddf7a8e6..4a7744ec 100755
--- a/vendor/OAuth/OAuth2/Service/Vkontakte.php
+++ b/vendor/OAuth/OAuth2/Service/Vkontakte.php
@@ -17,6 +17,7 @@ class Vkontakte extends AbstractService
*
* @link http://vk.com/dev/permissions
*/
+ const SCOPE_EMAIL = 'email';
const SCOPE_NOTIFY = 'notify';
const SCOPE_FRIENDS = 'friends';
const SCOPE_PHOTOS = 'photos';