Merge pull request #342 from gaomd/master

Fix #328, strict check Bearer token
This commit is contained in:
Alex Bilbie 2015-08-21 09:00:02 +01:00
commit 2496653968

View File

@ -38,9 +38,16 @@ class Bearer extends AbstractTokenType implements TokenTypeInterface
*/
public function determineAccessTokenInHeader(Request $request)
{
$header = $request->headers->get('Authorization');
$accessToken = trim(preg_replace('/^(?:\s+)?Bearer\s/', '', $header));
if ($request->headers->has('Authorization') === false) {
return;
}
return ($accessToken === 'Bearer') ? '' : $accessToken;
$header = $request->headers->get('Authorization');
if (substr($header, 0, 7) !== 'Bearer ') {
return;
}
return trim(substr($header, 7));
}
}