Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a8f0981377 | ||
|
7d9da4ac73 | ||
|
94f5dcd4e5 | ||
|
fb15b5652a | ||
|
20399c4ae7 |
|
@ -18,6 +18,7 @@
|
|||
},
|
||||
"require" : {
|
||||
"php" : ">=5.4",
|
||||
"meta-tech/pws-auth" : "^2.1"
|
||||
"meta-tech/pws-auth" : "@dev",
|
||||
"symfony/yaml": "^3.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@ class Client
|
|||
/*! @protected @var Mtc\Core\Auth\Authenticator $authenticator */
|
||||
protected $authenticator;
|
||||
|
||||
/*! @protected @var str $responseToken */
|
||||
protected $responseToken;
|
||||
|
||||
/*!
|
||||
* desc
|
||||
*
|
||||
|
@ -173,6 +176,8 @@ class Client
|
|||
private function _buildHeader($sessid=null)
|
||||
{
|
||||
$header = $this->authenticator->generateHeader($this->config['login'], $this->config['key'], $sessid);
|
||||
$token = $this->authenticator->getToken($this->authenticator->readHeader($header));
|
||||
$this->responseToken = $this->authenticator->generateResponseHeader($token, $this->config['login']);
|
||||
return $header;
|
||||
}
|
||||
|
||||
|
@ -267,6 +272,23 @@ class Client
|
|||
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
$size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
||||
$respheader = substr($rs, 0, $size);
|
||||
$authresponse = false;
|
||||
try {
|
||||
$lines = explode(PHP_EOL, $respheader);
|
||||
$arrheader = [];
|
||||
foreach($lines as $line) {
|
||||
if (!empty($line)) {
|
||||
$match = preg_split('/: /', $line, 2);
|
||||
if (count($match)==2) {
|
||||
$arrheader[$match[0]] = trim($match[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$authresponse = isset($arrheader['Pws-Response']) && $arrheader['Pws-Response'] == $this->responseToken;
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
|
||||
}
|
||||
$body = substr($rs, $size);
|
||||
$response = json_decode($body);
|
||||
$url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
|
||||
|
@ -285,6 +307,7 @@ class Client
|
|||
}
|
||||
}
|
||||
if ($this->config['debug']) {
|
||||
$responseToken = $this->responseToken;
|
||||
$respcontent = null;
|
||||
if (is_object($response)) {
|
||||
$respcontent = clone $response;
|
||||
|
@ -316,7 +339,7 @@ class Client
|
|||
'HEADER' => $this->authenticator->readHeader($header),
|
||||
'PARAMS' => $data,
|
||||
'METHOD' => $method,
|
||||
'RESPONSE' => compact('date', 'uri', 'status') + ['curl' => $rs, 'response' => $respcontent]
|
||||
'RESPONSE' => compact('date', 'uri', 'status', 'responseToken', 'authresponse') + ['curl' => $rs, 'response' => $respcontent]
|
||||
], true) . Formatter::LF;
|
||||
array_unshift($tags, $traces);
|
||||
$this->formatter->writeTags($tags);
|
||||
|
@ -324,11 +347,15 @@ class Client
|
|||
|
||||
case self::VERBOOSE :
|
||||
array_unshift($tags, Formatter::LF);
|
||||
$tags[] = var_export(compact('status')+['response' => $respcontent], true);
|
||||
$tags[] = var_export(compact('status', 'authresponse')+['response' => $respcontent], true);
|
||||
$this->formatter->writeTags($tags);
|
||||
break;
|
||||
}
|
||||
return compact('date', 'uri', 'response', 'status', 'exectime');
|
||||
if (!$authresponse) {
|
||||
$response->done = false;
|
||||
$response->msg = 'server response not authenticated !';
|
||||
}
|
||||
return compact('date', 'uri', 'response', 'status', 'exectime', 'authresponse');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user