/** * This method is called before every other service method and tries to * authenticate an incoming request using the first argument as an so * called "api key". If the "api key", the functions name and the remote IP * pass the access rules, the request will be authorized, otherwise a fault * is sent back to the caller. * * @param string the function's name. * @param array an array of arguments that will be delivered to the function. * * @return mixed if this method returns a Studip_Ws_Fault, further * processing will be aborted */ function before_filter($name, &$args) { $api_key = current($args); if (!WebserviceAccessRule::checkAccess($api_key, $name, $_SERVER['REMOTE_ADDR'])) { return new Studip_Ws_Fault('Could not authenticate client.'); } }
/** * reload all rules from database */ function get_all_rules() { $this->ws_rules = array(); foreach (WebserviceAccessRule::findAll() as $rule) { $this->ws_rules[$rule->id] = $rule; } }