Created
March 8, 2016 08:47
-
-
Save abcsun/0a6e8687ee21b59595ec to your computer and use it in GitHub Desktop.
JWT中解析http header中的authorization中所携带的token值
This file contains hidden or 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
/** | |
* 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