Fix #328, strict check Bearer token

This commit is contained in:
Mengdi Gao 2015-06-01 21:36:44 +08:00
parent c174b6fc65
commit 7934c7bb53

View File

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