-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
99 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the GesdinetJWTRefreshTokenBundle package. | ||
* | ||
* (c) Gesdinet <http://www.gesdinet.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gesdinet\JWTRefreshTokenBundle\Request; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class RequestRefreshToken | ||
{ | ||
public static function getRefreshToken(Request $request) | ||
{ | ||
if ($request->headers->get('content_type') == 'application/json') { | ||
$content = $request->getContent(); | ||
$params = !empty($content) ? json_decode($content, true) : array(); | ||
$refreshTokenString = trim($params['refresh_token']); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
} elseif (null !== $request->get('refresh_token')) { | ||
$refreshTokenString = $request->get('refresh_token'); | ||
} else { | ||
$refreshTokenString = $request->request->get('refresh_token'); | ||
} | ||
|
||
return $refreshTokenString; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ code_coverage: | |
- Entity | ||
- EventListener | ||
- Model | ||
- Request | ||
- Security | ||
- Service | ||
format: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace spec\Gesdinet\JWTRefreshTokenBundle\Request; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class RequestRefreshTokenSpec extends ObjectBehavior | ||
{ | ||
public function it_gets_from_query_param() | ||
{ | ||
$request = Request::createFromGlobals(); | ||
$request->attributes->set('refresh_token', 'abcd'); | ||
|
||
$this::getRefreshToken($request)->shouldBe('abcd'); | ||
} | ||
|
||
public function it_gets_from_body() | ||
{ | ||
$request = Request::createFromGlobals(); | ||
$request->request->set('refresh_token', 'abcd'); | ||
|
||
$this::getRefreshToken($request)->shouldBe('abcd'); | ||
} | ||
|
||
public function it_gets_from_json() | ||
{ | ||
$request = Request::create(null, 'POST', array(), array(), array(), array(), json_encode(array('refresh_token' => 'abcd'))); | ||
$request->headers->set('content_type', 'application/json'); | ||
|
||
$this::getRefreshToken($request)->shouldBe('abcd'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello, now api consumer always forced on authorization provide key empty or false "refresh_token" other way no index "refresh_token" found notice will be returned.
may be it would be better to change this row to next one:
case: i do POST to my auth route with _username and _password parameters and with Content-Type = application/json