Skip to content

Commit 39520a9

Browse files
committed
fixes bshaffer#191 - passes config to HttpBasic
1 parent 1a3340d commit 39520a9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/OAuth2/Server.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function __construct($storage = array(), array $config = array(), array $
102102
'enforce_state' => true,
103103
'require_exact_redirect_uri' => true,
104104
'allow_implicit' => false,
105+
'allow_credentials_in_request_body' => true,
105106
), $config);
106107

107108
foreach ($grantTypes as $key => $grantType) {
@@ -387,7 +388,8 @@ protected function createDefaultTokenController()
387388
if (!isset($this->storages['client_credentials'])) {
388389
throw new \LogicException("You must supply a storage object implementing OAuth2\Storage\ClientCredentialsInterface to use the token server");
389390
}
390-
$this->clientAssertionType = new HttpBasic($this->storages['client_credentials']);
391+
$config = array_intersect_key($this->config, array('allow_credentials_in_request_body' => ''));
392+
$this->clientAssertionType = new HttpBasic($this->storages['client_credentials'], $config);
391393
break;
392394
}
393395
}

test/OAuth2/ServerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,22 @@ public function testCustomClientAssertionType()
249249
$server->handleTokenRequest($request, $response = new Response());
250250
}
251251

252+
public function testHttpBasicConfig()
253+
{
254+
// create mock storage
255+
$storage = Bootstrap::getInstance()->getMemoryStorage();
256+
$server = new Server(array($storage), array('allow_credentials_in_request_body' => false));
257+
$server->getTokenController();
258+
$httpBasic = $server->getClientAssertionType();
259+
260+
$reflection = new \ReflectionClass($httpBasic);
261+
$prop = $reflection->getProperty('config');
262+
$prop->setAccessible(true);
263+
264+
$config = $prop->getValue($httpBasic); // get the private "storages" property
265+
$this->assertEquals($config['allow_credentials_in_request_body'], false);
266+
}
267+
252268
/**
253269
* @expectedException InvalidArgumentException OAuth2\ResponseType\AuthorizationCodeInterface
254270
**/

0 commit comments

Comments
 (0)