Go to the documentation of this file.
17 $this->config = array_merge(array(
18 'token_param_name' =>
'access_token',
19 'token_bearer_header_name' =>
'Bearer',
35 $headers = $request->
headers(
'AUTHORIZATION');
38 return !
empty($headers) || (bool) ($request->
request($this->config[
'token_param_name'])) || (
bool) ($request->
query($this->config[
'token_param_name']));
65 $headers = $request->
headers(
'AUTHORIZATION');
73 $methodsUsed = !
empty($headers) + (bool) ($request->
query($this->config[
'token_param_name'])) + (
bool) ($request->
request($this->config[
'token_param_name']));
74 if ($methodsUsed > 1) {
75 $response->
setError(400,
'invalid_request',
'Only one method may be used to authenticate at a time (Auth header, GET or POST)');
86 if ($methodsUsed == 0) {
93 if (!
empty($headers)) {
94 if (!preg_match(
'/' . $this->config[
'token_bearer_header_name'] .
'\s(\S+)/i', $headers, $matches)) {
95 $response->
setError(400,
'invalid_request',
'Malformed auth header');
103 if ($request->
request($this->config[
'token_param_name'])) {
105 if (!in_array(strtolower($request->
server(
'REQUEST_METHOD')), array(
'post',
'put'))) {
106 $response->
setError(400,
'invalid_request',
'When putting the token in the body, the method must be POST or PUT',
'#section-2.2');
111 $contentType = $request->
server(
'CONTENT_TYPE');
112 if (
false !== $pos = strpos($contentType,
';')) {
113 $contentType = substr($contentType, 0, $pos);
116 if ($contentType !==
null && $contentType !=
'application/x-www-form-urlencoded') {
119 $response->
setError(400,
'invalid_request',
'The content type for POST requests must be "application/x-www-form-urlencoded"');
124 return $request->
request($this->config[
'token_param_name']);
128 return $request->
query($this->config[
'token_param_name']);
request($name, $default=null)
setStatusCode($statusCode)
server($name, $default=null)
__construct(array $config=array())
GNU LESSER GENERAL PUBLIC LICENSE February Free Software Inc Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license but changing it is not allowed[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it By the GNU General Public Licenses are intended to guarantee your freedom to share and change free software to make sure the software is free for all its users This the Lesser General Public applies to some specially designated software packages typically libraries of the Free Software Foundation and other authors who decide to use it You can use it but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular based on the explanations below When we speak of free we are referring to freedom of use
requestHasToken(RequestInterface $request)
setError($statusCode, $name, $description=null, $uri=null)
headers($name, $default=null)
getAccessTokenParameter(RequestInterface $request, ResponseInterface $response)
query($name, $default=null)
Attr AllowedRel this is empty