Skip to content

Instantly share code, notes, and snippets.

@abcsun
Created March 8, 2016 08:47
Show Gist options
  • Save abcsun/0a6e8687ee21b59595ec to your computer and use it in GitHub Desktop.
Save abcsun/0a6e8687ee21b59595ec to your computer and use it in GitHub Desktop.
JWT中解析http header中的authorization中所携带的token值
/**
* Parse token from the authorization header.
*
* @param string $header
* @param string $method
*
* @return false|string
*/
protected function parseAuthHeader($header = 'authorization', $method = 'bearer')
{
$header = $this->request->headers->get($header);
if (! starts_with(strtolower($header), $method)) {
return false;
}
return trim(str_ireplace($method, '', $header));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment