aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/bshaffer/oauth2-server-php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-01-02 22:41:03 +0100
committerMario Vavti <mario@mariovavti.com>2019-01-02 22:41:03 +0100
commitdbd230da7407ac70483c004bc82f4b8619c42760 (patch)
tree14e016f85e6a8466a2dfcdbeadaab0adb8cff153 /vendor/bshaffer/oauth2-server-php
parenta19563e1396cb882063db3ce3f355b2db48175e9 (diff)
downloadvolse-hubzilla-dbd230da7407ac70483c004bc82f4b8619c42760.tar.gz
volse-hubzilla-dbd230da7407ac70483c004bc82f4b8619c42760.tar.bz2
volse-hubzilla-dbd230da7407ac70483c004bc82f4b8619c42760.zip
update composer libs
Diffstat (limited to 'vendor/bshaffer/oauth2-server-php')
-rw-r--r--vendor/bshaffer/oauth2-server-php/CHANGELOG.md4
-rw-r--r--vendor/bshaffer/oauth2-server-php/README.md2
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/Request.php7
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/Response.php2
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/ResponseType/JwtAccessToken.php18
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/Server.php9
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php18
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php23
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php21
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php8
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/lib/OAuth2/Storage/Bootstrap.php2
11 files changed, 97 insertions, 17 deletions
diff --git a/vendor/bshaffer/oauth2-server-php/CHANGELOG.md b/vendor/bshaffer/oauth2-server-php/CHANGELOG.md
index 7671b2396..1b87f3da3 100644
--- a/vendor/bshaffer/oauth2-server-php/CHANGELOG.md
+++ b/vendor/bshaffer/oauth2-server-php/CHANGELOG.md
@@ -8,7 +8,7 @@ To see the files changed for a given bug, go to https://github.com/bshaffer/oaut
To get the diff between two versions, go to https://github.com/bshaffer/oauth2-server-php/compare/v1.0...v1.1
To get the diff for a specific change, go to https://github.com/bshaffer/oauth2-server-php/commit/XXX where XXX is the change hash
-* 1.10.0 (2017-12-14)
+* 1.10.0 (2017-11-15)
PR: https://github.com/bshaffer/oauth2-server-php/pull/889
@@ -26,7 +26,7 @@ To get the diff for a specific change, go to https://github.com/bshaffer/oauth2-
* #794 - [docs] Fix typo in composer.json
* #885 - [testing] Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase
-* 1.9.0 (2016-01-06)
+* 1.9.0 (2017-01-06)
PR: https://github.com/bshaffer/oauth2-server-php/pull/788
diff --git a/vendor/bshaffer/oauth2-server-php/README.md b/vendor/bshaffer/oauth2-server-php/README.md
index f1788e9ce..117743d4f 100644
--- a/vendor/bshaffer/oauth2-server-php/README.md
+++ b/vendor/bshaffer/oauth2-server-php/README.md
@@ -1,7 +1,7 @@
oauth2-server-php
=================
-[![Build Status](https://travis-ci.org/bshaffer/oauth2-server-php.svg?branch=develop)](https://travis-ci.org/bshaffer/oauth2-server-php)
+[![Build Status](https://travis-ci.org/bshaffer/oauth2-server-php.svg?branch=master)](https://travis-ci.org/bshaffer/oauth2-server-php)
[![Total Downloads](https://poser.pugx.org/bshaffer/oauth2-server-php/downloads.png)](https://packagist.org/packages/bshaffer/oauth2-server-php)
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/Request.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/Request.php
index c96cb972f..f547bf6e8 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/Request.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/Request.php
@@ -64,7 +64,12 @@ class Request implements RequestInterface
$this->files = $files;
$this->server = $server;
$this->content = $content;
- $this->headers = is_null($headers) ? $this->getHeadersFromServer($this->server) : $headers;
+
+ if ($headers === null) {
+ $headers = array();
+ }
+
+ $this->headers = $headers + $this->getHeadersFromServer($this->server);
}
/**
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/Response.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/Response.php
index ccd797ae7..88c1ad5f7 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/Response.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/Response.php
@@ -366,7 +366,7 @@ class Response implements ResponseInterface
if (count($this->parameters) > 0) {
// add parameters to URL redirection
$parts = parse_url($url);
- $sep = isset($parts['query']) && count($parts['query']) > 0 ? '&' : '?';
+ $sep = isset($parts['query']) && !empty($parts['query']) ? '&' : '?';
$url .= $sep . http_build_query($this->parameters);
}
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/ResponseType/JwtAccessToken.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/ResponseType/JwtAccessToken.php
index 0af9705ff..0ee3708aa 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/ResponseType/JwtAccessToken.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/ResponseType/JwtAccessToken.php
@@ -128,7 +128,7 @@ class JwtAccessToken extends AccessToken
$expires = time() + $this->config['access_lifetime'];
$id = $this->generateAccessToken();
- return array(
+ $payload = array(
'id' => $id, // for BC (see #591)
'jti' => $id,
'iss' => $this->config['issuer'],
@@ -139,5 +139,21 @@ class JwtAccessToken extends AccessToken
'token_type' => $this->config['token_type'],
'scope' => $scope
);
+
+ if (isset($this->config['jwt_extra_payload_callable'])) {
+ if (!is_callable($this->config['jwt_extra_payload_callable'])) {
+ throw new \InvalidArgumentException('jwt_extra_payload_callable is not callable');
+ }
+
+ $extra = call_user_func($this->config['jwt_extra_payload_callable'], $client_id, $user_id, $scope);
+
+ if (!is_array($extra)) {
+ throw new \InvalidArgumentException('jwt_extra_payload_callable must return array');
+ }
+
+ $payload = array_merge($extra, $payload);
+ }
+
+ return $payload;
}
}
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/Server.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/Server.php
index 62ae8970d..cf040c2bc 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/Server.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/Server.php
@@ -88,12 +88,12 @@ class Server implements ResourceControllerInterface,
/**
* @var array
*/
- protected $grantTypes = [];
+ protected $grantTypes = array();
/**
* @var array
*/
- protected $responseTypes = [];
+ protected $responseTypes = array();
/**
* @var TokenTypeInterface
@@ -161,6 +161,7 @@ class Server implements ResourceControllerInterface,
// merge all config values. These get passed to our controller objects
$this->config = array_merge(array(
'use_jwt_access_tokens' => false,
+ 'jwt_extra_payload_callable' => null,
'store_encrypted_token_string' => true,
'use_openid_connect' => false,
'id_lifetime' => 3600,
@@ -840,7 +841,7 @@ class Server implements ResourceControllerInterface,
$refreshStorage = $this->storages['refresh_token'];
}
- $config = array_intersect_key($this->config, array_flip(explode(' ', 'store_encrypted_token_string issuer access_lifetime refresh_token_lifetime')));
+ $config = array_intersect_key($this->config, array_flip(explode(' ', 'store_encrypted_token_string issuer access_lifetime refresh_token_lifetime jwt_extra_payload_callable')));
return new JwtAccessToken($this->storages['public_key'], $tokenStorage, $refreshStorage, $config);
}
@@ -1015,4 +1016,4 @@ class Server implements ResourceControllerInterface,
{
return isset($this->config[$name]) ? $this->config[$name] : $default;
}
-} \ No newline at end of file
+}
diff --git a/vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php b/vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php
index cbf8f096b..770cd8994 100644
--- a/vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php
+++ b/vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php
@@ -86,6 +86,24 @@ class RequestTest extends TestCase
$this->assertEquals('correct', $request->query('client_id', $request->request('client_id')));
}
+ public function testRequestHasHeadersAndServerHeaders()
+ {
+ $request = new Request(
+ array(),
+ array(),
+ array(),
+ array(),
+ array(),
+ array('CONTENT_TYPE' => 'text/xml', 'PHP_AUTH_USER' => 'client_id', 'PHP_AUTH_PW' => 'client_pass'),
+ null,
+ array('CONTENT_TYPE' => 'application/json')
+ );
+
+ $this->assertSame('client_id', $request->headers('PHP_AUTH_USER'));
+ $this->assertSame('client_pass', $request->headers('PHP_AUTH_PW'));
+ $this->assertSame('application/json', $request->headers('CONTENT_TYPE'));
+ }
+
private function getTestServer($config = array())
{
$storage = Bootstrap::getInstance()->getMemoryStorage();
diff --git a/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php b/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php
index 2d2c57ee6..172bc88fd 100644
--- a/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php
+++ b/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php
@@ -1,6 +1,8 @@
<?php
-namespace OAuth2;use PHPUnit\Framework\TestCase;
+namespace OAuth2;
+
+use PHPUnit\Framework\TestCase;
class ResponseTest extends TestCase
{
@@ -14,4 +16,23 @@ class ResponseTest extends TestCase
$string = $response->getResponseBody('xml');
$this->assertContains('<response><foo>bar</foo><halland>oates</halland></response>', $string);
}
+
+ public function testSetRedirect()
+ {
+ $response = new Response();
+ $url = 'https://foo/bar';
+ $state = 'stateparam';
+ $response->setRedirect(301, $url, $state);
+ $this->assertEquals(
+ sprintf('%s?state=%s', $url, $state),
+ $response->getHttpHeader('Location')
+ );
+
+ $query = 'query=foo';
+ $response->setRedirect(301, $url . '?' . $query, $state);
+ $this->assertEquals(
+ sprintf('%s?%s&state=%s', $url, $query, $state),
+ $response->getHttpHeader('Location')
+ );
+ }
}
diff --git a/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php b/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php
index 7e37509ef..6195d557a 100644
--- a/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php
+++ b/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php
@@ -40,6 +40,23 @@ class JwtAccessTokenTest extends TestCase
$this->assertEquals(3600, $delta);
$this->assertEquals($decodedAccessToken['id'], $decodedAccessToken['jti']);
}
+
+ public function testExtraPayloadCallback()
+ {
+ $jwtconfig = array('jwt_extra_payload_callable' => function() {
+ return array('custom_param' => 'custom_value');
+ });
+
+ $server = $this->getTestServer($jwtconfig);
+ $jwtResponseType = $server->getResponseType('token');
+
+ $accessToken = $jwtResponseType->createAccessToken('Test Client ID', 123, 'test', false);
+ $jwt = new Jwt;
+ $decodedAccessToken = $jwt->decode($accessToken['access_token'], null, false);
+
+ $this->assertArrayHasKey('custom_param', $decodedAccessToken);
+ $this->assertEquals('custom_value', $decodedAccessToken['custom_param']);
+ }
public function testGrantJwtAccessToken()
{
@@ -140,7 +157,7 @@ class JwtAccessTokenTest extends TestCase
$this->assertNotNull($response->getParameter('access_token'));
}
- private function getTestServer()
+ private function getTestServer($jwtconfig = array())
{
$memoryStorage = Bootstrap::getInstance()->getMemoryStorage();
@@ -153,7 +170,7 @@ class JwtAccessTokenTest extends TestCase
$server->addGrantType(new ClientCredentials($memoryStorage));
// make the "token" response type a JwtAccessToken
- $config = array('issuer' => 'https://api.example.com');
+ $config = array_merge(array('issuer' => 'https://api.example.com'), $jwtconfig);
$server->addResponseType(new JwtAccessToken($memoryStorage, $memoryStorage, null, $config));
return $server;
diff --git a/vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php b/vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php
index 57eb39072..4599f69bf 100644
--- a/vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php
+++ b/vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php
@@ -6,7 +6,8 @@ class PdoTest extends BaseTest
{
public function testCreatePdoStorageUsingPdoClass()
{
- $pdo = new \PDO(sprintf('sqlite://%s', Bootstrap::getInstance()->getSqliteDir()));
+ $dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir());
+ $pdo = new \PDO($dsn);
$storage = new Pdo($pdo);
$this->assertNotNull($storage->getClientDetails('oauth_test_client'));
@@ -14,7 +15,7 @@ class PdoTest extends BaseTest
public function testCreatePdoStorageUsingDSN()
{
- $dsn = sprintf('sqlite://%s', Bootstrap::getInstance()->getSqliteDir());
+ $dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir());
$storage = new Pdo($dsn);
$this->assertNotNull($storage->getClientDetails('oauth_test_client'));
@@ -22,7 +23,8 @@ class PdoTest extends BaseTest
public function testCreatePdoStorageUsingConfig()
{
- $config = array('dsn' => sprintf('sqlite://%s', Bootstrap::getInstance()->getSqliteDir()));
+ $dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir());
+ $config = array('dsn' => $dsn);
$storage = new Pdo($config);
$this->assertNotNull($storage->getClientDetails('oauth_test_client'));
diff --git a/vendor/bshaffer/oauth2-server-php/test/lib/OAuth2/Storage/Bootstrap.php b/vendor/bshaffer/oauth2-server-php/test/lib/OAuth2/Storage/Bootstrap.php
index 3d7bdd4e9..8e428f9b5 100644
--- a/vendor/bshaffer/oauth2-server-php/test/lib/OAuth2/Storage/Bootstrap.php
+++ b/vendor/bshaffer/oauth2-server-php/test/lib/OAuth2/Storage/Bootstrap.php
@@ -36,7 +36,7 @@ class Bootstrap
{
if (!$this->sqlite) {
$this->removeSqliteDb();
- $pdo = new \PDO(sprintf('sqlite://%s', $this->getSqliteDir()));
+ $pdo = new \PDO(sprintf('sqlite:%s', $this->getSqliteDir()));
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$this->createSqliteDb($pdo);