CC-5701: Airtime File API
This commit is contained in:
parent
f33f49259d
commit
b6dd2e3152
|
@ -106,7 +106,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
if (!$id = $this->_getParam('id', false)) {
|
if (!$id = $this->_getParam('id', false)) {
|
||||||
$resp = $this->getResponse();
|
$resp = $this->getResponse();
|
||||||
$resp->setHttpResponseCode(400);
|
$resp->setHttpResponseCode(400);
|
||||||
$resp->appendBody("ERROR: No show ID specified.");
|
$resp->appendBody("ERROR: No file ID specified.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $id;
|
return $id;
|
||||||
|
@ -115,23 +115,15 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
private function verifyAPIKey()
|
private function verifyAPIKey()
|
||||||
{
|
{
|
||||||
//The API key is passed in via HTTP "basic authentication":
|
//The API key is passed in via HTTP "basic authentication":
|
||||||
// http://en.wikipedia.org/wiki/Basic_access_authentication
|
// http://en.wikipedia.org/wiki/Basic_access_authentication
|
||||||
|
|
||||||
//TODO: Fetch the user's API key from the database to check against
|
$CC_CONFIG = Config::getConfig();
|
||||||
$unencodedStoredApiKey = "foobar";
|
|
||||||
$encodedStoredApiKey = base64_encode($unencodedStoredApiKey . ":");
|
|
||||||
|
|
||||||
//Decode the API key that was passed to us in the HTTP request.
|
|
||||||
$authHeader = $this->getRequest()->getHeader("Authorization");
|
$authHeader = $this->getRequest()->getHeader("Authorization");
|
||||||
$encodedRequestApiKey = substr($authHeader, strlen("Basic "));
|
|
||||||
|
|
||||||
//if ($encodedRequestApiKey === $encodedStoredApiKey)
|
if (in_array($authHeader, $CC_CONFIG["apiKey"])) {
|
||||||
if (true)
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$resp = $this->getResponse();
|
$resp = $this->getResponse();
|
||||||
$resp->setHttpResponseCode(401);
|
$resp->setHttpResponseCode(401);
|
||||||
$resp->appendBody("ERROR: Incorrect API key.");
|
$resp->appendBody("ERROR: Incorrect API key.");
|
||||||
|
|
Loading…
Reference in New Issue