From a1f29372c1cfdbd6c4ce0ed369e9ee366f02036b Mon Sep 17 00:00:00 2001 From: Kiel Goodman Date: Wed, 8 Jul 2015 16:03:13 +0100 Subject: [PATCH 1/3] Check POST data first, then fallback to GET on client_id/client_secret --- .../LicensingClientBundle/Controller/TokenController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Vivait/LicensingClientBundle/Controller/TokenController.php b/src/Vivait/LicensingClientBundle/Controller/TokenController.php index 759eb7d..ebca387 100644 --- a/src/Vivait/LicensingClientBundle/Controller/TokenController.php +++ b/src/Vivait/LicensingClientBundle/Controller/TokenController.php @@ -25,9 +25,9 @@ public function tokenAction(Request $request) try { $tokenData = $licensingApi->getToken( - $request->query->get('client_id', null), - $request->query->get('client_secret', null), - $request->query->get('grant_type', 'client_credentials') + $request->request->get('client_id', $request->query->get('client_id', null)), + $request->request->get('client_secret', $request->query->get('client_secret', null)), + $request->request->get('grant_type', $request->query->get('grant_type', 'client_credentials')), ); $clientData = $licensingApi->getClient($tokenData['access_token']); @@ -69,4 +69,4 @@ public function exceptionAction(Request $request) -} \ No newline at end of file +} From 544be2490560f2364a6909737f90801916696be3 Mon Sep 17 00:00:00 2001 From: Kiel Goodman Date: Wed, 8 Jul 2015 16:25:18 +0100 Subject: [PATCH 2/3] Uses specific POST or GET parameter requests depending on method --- .../Controller/TokenController.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Vivait/LicensingClientBundle/Controller/TokenController.php b/src/Vivait/LicensingClientBundle/Controller/TokenController.php index ebca387..78efaaa 100644 --- a/src/Vivait/LicensingClientBundle/Controller/TokenController.php +++ b/src/Vivait/LicensingClientBundle/Controller/TokenController.php @@ -24,11 +24,20 @@ public function tokenAction(Request $request) $licensingApi = $this->get('vivait_licensing_client.licensing.api'); try { - $tokenData = $licensingApi->getToken( - $request->request->get('client_id', $request->query->get('client_id', null)), - $request->request->get('client_secret', $request->query->get('client_secret', null)), - $request->request->get('grant_type', $request->query->get('grant_type', 'client_credentials')), - ); + if($request->getMethod() == 'POST') { + $tokenData = $licensingApi->getToken( + $request->request->get('client_id', null), + $request->request->get('client_secret', null), + $request->request->get('grant_type', 'client_credentials') + ); + } else { + $tokenData = $licensingApi->getToken( + $request->query->get('client_id', null), + $request->query->get('client_secret', null), + $request->query->get('grant_type', 'client_credentials') + ); + + } $clientData = $licensingApi->getClient($tokenData['access_token']); } catch (HttpException $e) { From d09f8f43653e5556f17b28dbd7e6c62ef3c387e9 Mon Sep 17 00:00:00 2001 From: Kiel Goodman Date: Wed, 8 Jul 2015 16:42:00 +0100 Subject: [PATCH 3/3] Less prone to copy/paste errors --- .../Controller/TokenController.php | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Vivait/LicensingClientBundle/Controller/TokenController.php b/src/Vivait/LicensingClientBundle/Controller/TokenController.php index 78efaaa..8f36393 100644 --- a/src/Vivait/LicensingClientBundle/Controller/TokenController.php +++ b/src/Vivait/LicensingClientBundle/Controller/TokenController.php @@ -25,19 +25,17 @@ public function tokenAction(Request $request) try { if($request->getMethod() == 'POST') { - $tokenData = $licensingApi->getToken( - $request->request->get('client_id', null), - $request->request->get('client_secret', null), - $request->request->get('grant_type', 'client_credentials') - ); + $parameters = $request->request; } else { - $tokenData = $licensingApi->getToken( - $request->query->get('client_id', null), - $request->query->get('client_secret', null), - $request->query->get('grant_type', 'client_credentials') - ); - + $parameters = $request->query; } + + $tokenData = $licensingApi->getToken( + $parameters->get('client_id', null), + $parameters->get('client_secret', null), + $parameters->get('grant_type', 'client_credentials') + ); + $clientData = $licensingApi->getClient($tokenData['access_token']); } catch (HttpException $e) {