Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
4f352302a1 | |||
![]() |
cc7992f2d1 | ||
5616fa0756 | |||
f8ffcd6f87 | |||
e4e8bc2f90 | |||
![]() |
4011b3674d | ||
![]() |
fdb6c2df49 | ||
![]() |
da8c3c46c5 | ||
![]() |
cec7f31cda | ||
ca5c3596dc | |||
b3d4f9b6bc | |||
![]() |
087cb1278f |
14
.gitattributes
vendored
Normal file
14
.gitattributes
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Text files.
|
||||||
|
*.ini text
|
||||||
|
*.json text
|
||||||
|
*.md text
|
||||||
|
*.php text diff=php
|
||||||
|
*.phtml text diff=html
|
||||||
|
*.xml text
|
||||||
|
|
||||||
|
# Binary files.
|
||||||
|
*.alaw binary
|
||||||
|
*.gif binary
|
||||||
|
*.phar binary
|
||||||
|
*.png binary
|
||||||
|
*.wav binary
|
@@ -1,13 +1,8 @@
|
|||||||
language: php
|
language: php
|
||||||
php:
|
php:
|
||||||
- 5.3
|
|
||||||
- 5.4
|
- 5.4
|
||||||
- 5.5
|
- 5.5
|
||||||
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- php: 5.5
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer selfupdate --quiet
|
- composer selfupdate --quiet
|
||||||
- composer install --dev
|
- composer install --dev
|
||||||
|
10
CHANGELOG.md
Normal file
10
CHANGELOG.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Version 1.0.10 (2014-02-21)
|
||||||
|
|
||||||
|
* Made version parameter optional (@vimishor)
|
||||||
|
|
||||||
|
Version 1.0.9 (2013-11-19)
|
||||||
|
|
||||||
|
* Merged changes by @VictorBjelkholm. This results in a BC break:
|
||||||
|
Request\Request now requires the 'oauth_consumer_key' as a parameter
|
||||||
|
in the contructor.
|
||||||
|
|
10
CONTRIBUTORS.md
Normal file
10
CONTRIBUTORS.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
This project has had multiple authors. In this file, I will try to credit
|
||||||
|
each of them. If you are not listed for some reason, please ask.
|
||||||
|
|
||||||
|
Andy Smith authored the original code (http://oauth.googlecode.com/svn/code/php/).
|
||||||
|
|
||||||
|
* Alexandre Eher (@EHER)
|
||||||
|
* Gary Jones (@GaryJones)
|
||||||
|
* Jacob Kiers (@jacobkiers)
|
||||||
|
* Alexandru G. (@vimishor)
|
||||||
|
* Victor Bjelkholm (@VictorBjelkholm)
|
@@ -2,7 +2,7 @@
|
|||||||
<phpunit backupGlobals="false"
|
<phpunit backupGlobals="false"
|
||||||
backupStaticAttributes="false"
|
backupStaticAttributes="false"
|
||||||
bootstrap="vendor/autoload.php"
|
bootstrap="vendor/autoload.php"
|
||||||
colors="false"
|
colors="true"
|
||||||
convertErrorsToExceptions="true"
|
convertErrorsToExceptions="true"
|
||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
|
@@ -68,6 +68,10 @@ class Request implements RequestInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct($http_method, $http_url, array $parameters = null)
|
public function __construct($http_method, $http_url, array $parameters = null)
|
||||||
{
|
{
|
||||||
|
if(!isset($parameters['oauth_consumer_key'])) {
|
||||||
|
throw new OAuthException('You need a OAuth consumer key to proceed');
|
||||||
|
}
|
||||||
|
|
||||||
$parameters = ($parameters) ? $parameters : array();
|
$parameters = ($parameters) ? $parameters : array();
|
||||||
$this->parameters = array_merge(Util::parseParameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
|
$this->parameters = array_merge(Util::parseParameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
|
||||||
$this->http_method = $http_method;
|
$this->http_method = $http_method;
|
||||||
@@ -153,11 +157,10 @@ public static function fromConsumerAndToken(
|
|||||||
) {
|
) {
|
||||||
$parameters = ($parameters) ? $parameters : array();
|
$parameters = ($parameters) ? $parameters : array();
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'oauth_version' => Request::$version,
|
|
||||||
'oauth_nonce' => Request::generateNonce(),
|
'oauth_nonce' => Request::generateNonce(),
|
||||||
'oauth_timestamp' => Request::generateTimestamp(),
|
'oauth_timestamp' => Request::generateTimestamp(),
|
||||||
'oauth_consumer_key' => $consumer->getKey());
|
'oauth_consumer_key' => $consumer->getKey());
|
||||||
if ($token) {
|
if ($token->getKey()) {
|
||||||
$defaults['oauth_token'] = $token->getKey();
|
$defaults['oauth_token'] = $token->getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@ public function addSignatureMethod(SignatureMethodInterface $signature_method)
|
|||||||
*
|
*
|
||||||
* @return JacobKiers\OAuth\Token\TokenInterface
|
* @return JacobKiers\OAuth\Token\TokenInterface
|
||||||
*/
|
*/
|
||||||
public function fetchRequestToken(RequestInterface &$request)
|
public function fetchRequestToken(RequestInterface $request)
|
||||||
{
|
{
|
||||||
$this->getVersion($request);
|
$this->getVersion($request);
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ public function fetchRequestToken(RequestInterface &$request)
|
|||||||
*
|
*
|
||||||
* @return JacobKiers\OAuth\Token\TokenInterface
|
* @return JacobKiers\OAuth\Token\TokenInterface
|
||||||
*/
|
*/
|
||||||
public function fetchAccessToken(RequestInterface &$request)
|
public function fetchAccessToken(RequestInterface $request)
|
||||||
{
|
{
|
||||||
$this->getVersion($request);
|
$this->getVersion($request);
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ public function fetchAccessToken(RequestInterface &$request)
|
|||||||
*
|
*
|
||||||
* @return array Consumer and Token
|
* @return array Consumer and Token
|
||||||
*/
|
*/
|
||||||
public function verifyRequest(RequestInterface &$request)
|
public function verifyRequest(RequestInterface $request)
|
||||||
{
|
{
|
||||||
$this->getVersion($request);
|
$this->getVersion($request);
|
||||||
$consumer = $this->getConsumer($request);
|
$consumer = $this->getConsumer($request);
|
||||||
@@ -159,7 +159,7 @@ public function verifyRequest(RequestInterface &$request)
|
|||||||
*
|
*
|
||||||
* @throws JacobKiers\OAuth\OAuthException
|
* @throws JacobKiers\OAuth\OAuthException
|
||||||
*/
|
*/
|
||||||
private function getVersion(RequestInterface &$request)
|
private function getVersion(RequestInterface $request)
|
||||||
{
|
{
|
||||||
$version = $request->getOAuthVersion();
|
$version = $request->getOAuthVersion();
|
||||||
if (!$version) {
|
if (!$version) {
|
||||||
|
@@ -49,7 +49,7 @@ public function getName()
|
|||||||
* Either way should return a string representation of the certificate
|
* Either way should return a string representation of the certificate
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract protected function fetchPublicCert(&$request);
|
abstract protected function fetchPublicCert($request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Up to the SP to implement this lookup of keys. Possible ideas are:
|
* Up to the SP to implement this lookup of keys. Possible ideas are:
|
||||||
@@ -57,7 +57,7 @@ abstract protected function fetchPublicCert(&$request);
|
|||||||
*
|
*
|
||||||
* Either way should return a string representation of the certificate
|
* Either way should return a string representation of the certificate
|
||||||
*/
|
*/
|
||||||
abstract protected function fetchPrivateCert(&$request);
|
abstract protected function fetchPrivateCert($request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build up the signature.
|
* Build up the signature.
|
||||||
|
@@ -10,27 +10,34 @@ public function tearDown()
|
|||||||
m::close();
|
m::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \JacobKiers\OAuth\OAuthException
|
||||||
|
*/
|
||||||
|
public function testRequestThrowsExceptionWhenNoOAuthConsumerKeyIsPresent()
|
||||||
|
{
|
||||||
|
$request = new Request('POST', 'http://example.com', array());
|
||||||
|
}
|
||||||
public function testHttpMethodCanBeNormalized()
|
public function testHttpMethodCanBeNormalized()
|
||||||
{
|
{
|
||||||
$request = new Request('foo', 'bar');
|
$request = new Request('foo', 'bar', array('oauth_consumer_key' => 'bar'));
|
||||||
$this->assertEquals('FOO', $request->getNormalizedHttpMethod());
|
$this->assertEquals('FOO', $request->getNormalizedHttpMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHttpUrlCanBeNormalized()
|
public function testHttpUrlCanBeNormalized()
|
||||||
{
|
{
|
||||||
$request = new Request('foo', 'bar');
|
$request = new Request('foo', 'bar', array('oauth_consumer_key' => 'bar'));
|
||||||
$this->assertEquals('http://bar', $request->getNormalizedHttpUrl());
|
$this->assertEquals('http://bar', $request->getNormalizedHttpUrl());
|
||||||
$request = new Request('foo', 'example.com:80');
|
$request = new Request('foo', 'example.com:80', array('oauth_consumer_key' => 'bar'));
|
||||||
$this->assertEquals('http://example.com', $request->getNormalizedHttpUrl());
|
$this->assertEquals('http://example.com', $request->getNormalizedHttpUrl());
|
||||||
$request = new Request('foo', 'example.com:81');
|
$request = new Request('foo', 'example.com:81', array('oauth_consumer_key' => 'bar'));
|
||||||
$this->assertEquals('http://example.com:81', $request->getNormalizedHttpUrl());
|
$this->assertEquals('http://example.com:81', $request->getNormalizedHttpUrl());
|
||||||
$request = new Request('foo', 'https://example.com');
|
$request = new Request('foo', 'https://example.com', array('oauth_consumer_key' => 'bar'));
|
||||||
$this->assertEquals('https://example.com', $request->getNormalizedHttpUrl());
|
$this->assertEquals('https://example.com', $request->getNormalizedHttpUrl());
|
||||||
$request = new Request('foo', 'https://example.com:443');
|
$request = new Request('foo', 'https://example.com:443', array('oauth_consumer_key' => 'bar'));
|
||||||
$this->assertEquals('https://example.com', $request->getNormalizedHttpUrl());
|
$this->assertEquals('https://example.com', $request->getNormalizedHttpUrl());
|
||||||
$request = new Request('foo', 'http://example.com/foobar');
|
$request = new Request('foo', 'http://example.com/foobar', array('oauth_consumer_key' => 'bar'));
|
||||||
$this->assertEquals('http://example.com/foobar', $request->getNormalizedHttpUrl());
|
$this->assertEquals('http://example.com/foobar', $request->getNormalizedHttpUrl());
|
||||||
$request = new Request('foo', 'example.org:80/foobar');
|
$request = new Request('foo', 'example.org:80/foobar', array('oauth_consumer_key' => 'bar'));
|
||||||
$this->assertEquals('http://example.org/foobar', $request->getNormalizedHttpUrl());
|
$this->assertEquals('http://example.org/foobar', $request->getNormalizedHttpUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user