/** * This method will verify the data that has been passed and authorize it or not. * * It will return an error in case it does not authorize. * * @return mixed Error in case it is not valid True if it is for * partner, or if login is valid. */ public function authorize() { $valid = Frapi_Rules::isPartnerAction($this->getAction()); if (!$valid) { return false; } /** * Make sure the params needed are passed * if not, return an error with invalid partner * id/key */ $partnerID = isset($this->params['email']) ? $this->params['email'] : false; $partnerKey = isset($this->params['secretKey']) ? $this->params['secretKey'] : false; if (!empty($partnerID) && !empty($partnerKey)) { /** * Last step, validate the partner information * using the security Context */ $partnerID = $this->params['email']; $partnerKey = $this->params['secretKey']; $security = new Frapi_Security(); $securityPass = $security->isPartner($partnerID, $partnerKey); // Seems ok to me.. might as well go through. return true; } header('WWW-Authenticate: Basic realm="API Authentication"'); exit(0); }
/** * This method validates that the action type passed is a valid one. * * This method will look in the loginrequired and partnerId (pid) required * actions array for the key passed. If it's missing, it's not allowed. * * ANY ACTION must be either logged or contain partner id/key * * @param string $type The type to validate * @return bool Type is valid or it is not. */ public static function validateActionType($type) { if (!Frapi_Rules::isPartnerAction($type)) { return false; } return true; }
/** * This method will verify the data that has been passed and authorize it or not. * * It will return an error in case it does not authorize. * * @return mixed Error in case it is not valid True if it is for * partner, or if login is valid. */ public function authorize() { $valid = Frapi_Rules::isPartnerAction($this->getAction()); if (!$valid) { return false; } $auth = new Frapi_Authorization_HTTP_Digest(); /** * Make sure the params needed are passed * if not, return an error with invalid partner * id/key */ if (!empty($this->params['digest'])) { $authed = $auth->authorize(); return true; } $auth->send(); }