public function validateApiAccessControl() { if (kIpAddressUtils::isInternalIp()) { return true; } if ($this->getEnforceHttpsApi() && infraRequestUtils::getProtocol() != infraRequestUtils::PROTOCOL_HTTPS) { KalturaLog::err('Action was accessed over HTTP while the partner is configured for HTTPS access only'); return false; } $accessControl = $this->getApiAccessControl(); if (is_null($accessControl)) { return true; } $context = new kEntryContextDataResult(); $scope = new accessControlScope(); $scope->setKs(kCurrentContext::$ks); $scope->setContexts(array(ContextType::PLAY)); $disableCache = $accessControl->applyContext($context, $scope); if ($disableCache) { kApiCache::disableCache(); } if (count($context->getMessages())) { header("X-Kaltura-API-Access-Control: " . implode(', ', $context->getMessages())); } if (count($context->getActions())) { $actions = $context->getActions(); foreach ($actions as $action) { /* @var $action kAccessControlAction */ if ($action->getType() == RuleActionType::BLOCK) { KalturaLog::err('Action was blocked by API access control'); return false; } } } return true; }
public function apply() { if ($this->_cacheStatus == self::CACHE_STATUS_DISABLED) { kApiCache::disableCache(); return; } // common cache fields foreach ($this->_extraFields as $extraField) { call_user_func_array(array('kApiCache', 'addExtraField'), $extraField); } // anonymous cache fields if ($this->_expiry) { kApiCache::setExpiry($this->_expiry); } if ($this->_cacheStatus == self::CACHE_STATUS_ANONYMOUS_ONLY) { kApiCache::disableConditionalCache(); return; } // conditional cache fields if ($this->_conditionalCacheExpiry) { kApiCache::setConditionalCacheExpiry($this->_conditionalCacheExpiry); } kApiCache::addInvalidationKeys(array_keys($this->_invalidationKeys), $this->_invalidationTime); kApiCache::addSqlQueryConditions($this->_sqlConditions); }
/** * @param FileSync $fileSync * @param bool $tokenizeUrl * @return string */ public function getFileSyncUrl(FileSync $fileSync, $tokenizeUrl = true) { $fileSync = kFileSyncUtils::resolve($fileSync); $url = $this->doGetFileSyncUrl($fileSync); $url = str_replace('\\', '/', $url); if ($tokenizeUrl) { $tokenizer = $this->getTokenizer(); if ($tokenizer) { $url = $tokenizer->tokenizeSingleUrl($url, $this->getUrlPrefix()); kApiCache::disableCache(); } } return $url; }