summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorDominik Eckelmann <deckelmann@gmail.com>2012-01-08 15:31:46 +0100
committerDominik Eckelmann <deckelmann@gmail.com>2012-01-08 15:31:46 +0100
commit4beb39ea51a46409ab3abd4a1b880bf5d3d5dc4a (patch)
treed0aabd471dbfd76f2d13ab6e685c60b0a2abbaf3 /inc
parenta317247b19c498f4292480110cf0e0a1ce9780e8 (diff)
downloadrpg-4beb39ea51a46409ab3abd4a1b880bf5d3d5dc4a.tar.gz
rpg-4beb39ea51a46409ab3abd4a1b880bf5d3d5dc4a.tar.bz2
enforce acl on remote method call
Diffstat (limited to 'inc')
-rw-r--r--inc/remote.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/inc/remote.php b/inc/remote.php
index 94d428e8c..15d2308f8 100644
--- a/inc/remote.php
+++ b/inc/remote.php
@@ -82,7 +82,6 @@ class RemoteAPI {
* @return mixed result of method call, must be a primitive type.
*/
public function call($method, $args = array()) {
- $this->forceAccess();
list($type, $pluginName, $call) = explode('.', $method, 3);
if ($type === 'plugin') {
$plugin = plugin_load('remote', $pluginName);
@@ -90,10 +89,12 @@ class RemoteAPI {
if (!$plugin) {
throw new RemoteException('Method dose not exists');
}
+ $this->checkAccess($methods[$method]);
$name = $this->getMethodName($methods, $method);
return call_user_func_array(array($plugin, $name), $args);
} else {
$coreMethods = $this->getCoreMethods();
+ $this->checkAccess($coreMethods[$method]);
if (!isset($coreMethods[$method])) {
throw new RemoteException('Method dose not exists');
}
@@ -102,6 +103,16 @@ class RemoteAPI {
}
}
+ private function checkAccess($methodMeta) {
+ if (!isset($methodMeta['public'])) {
+ $this->forceAccess();
+ } else{
+ if ($methodMeta['public'] == '0') {
+ $this->forceAccess();
+ }
+ }
+ }
+
private function checkArgumentLength($method, $args) {
if (count($method['args']) < count($args)) {
throw new RemoteException('Method dose not exists - wrong parameter count.');
@@ -141,7 +152,7 @@ class RemoteAPI {
*/
public function forceAccess() {
if (!$this->hasAccess()) {
- throw new RemoteException('Access denied');
+ throw new RemoteAccessDenied();
}
}