Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "lusitanian/oauth",
"name": "jeroenvermeulen/oauth",
"description": "PHP 7.2 oAuth 1/2 Library",
"keywords": ["oauth", "authentication", "authorization", "security"],
"license": "MIT",
Expand All @@ -15,7 +15,11 @@
{
"name": "Elliot Chance",
"email": "[email protected]"
}
},
{
"name": "Jeroen Vermeulen",
"email": "[email protected]"
}
],
"scripts" : {
"tests" : [
Expand Down
5 changes: 0 additions & 5 deletions src/OAuth/Common/Token/AbstractToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,4 @@ public function isExpired()
&& $this->getEndOfLife() !== TokenInterface::EOL_UNKNOWN
&& time() > $this->getEndOfLife();
}

public function __sleep()
{
return ['accessToken'];
}
}
16 changes: 10 additions & 6 deletions src/OAuth/OAuth1/Service/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ abstract class AbstractService extends BaseAbstractService implements ServiceInt
/** @var null|UriInterface */
protected $baseApiUri;

/** @var string */
protected $signatureMethod = 'HMAC-SHA1';

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -243,7 +246,7 @@ protected function getBasicAuthorizationHeaderInfo()
'oauth_nonce' => $this->generateNonce(),
'oauth_signature_method' => $this->getSignatureMethod(),
'oauth_timestamp' => $dateTime->format('U'),
'oauth_version' => $this->getVersion(),
'oauth_version' => '1.0',
];

return $headerParameters;
Expand Down Expand Up @@ -274,17 +277,18 @@ protected function generateNonce($length = 32)
*/
protected function getSignatureMethod()
{
return 'HMAC-SHA1';
return $this->signatureMethod;
}

/**
* This returns the version used in the authorization header of the requests.
* Set the signature method.
* Currently supported: 'HMAC-SHA1' and 'HMAC-SHA256'
*
* @return string
* @param string $method
*/
protected function getVersion()
protected function setSignatureMethod($method)
{
return '1.0';
$this->signatureMethod = (string) $method;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/OAuth/OAuth1/Signature/Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ protected function hash($data)
switch (strtoupper($this->algorithm)) {
case 'HMAC-SHA1':
return hash_hmac('sha1', $data, $this->getSigningKey(), true);
case 'HMAC-SHA256':
return hash_hmac('sha256', $data, $this->getSigningKey(), true);
default:
throw new UnsupportedHashAlgorithmException(
'Unsupported hashing algorithm (' . $this->algorithm . ') used.'
Expand Down