/** * Constructor * * This is the constructor so people only have to instantiate * the object and benefit from the authentication mechanism provided * and built-in FRAPI. */ public function __construct() { $authorization = new Frapi_Authorization_HTTP_Digest('Testing Your App'); $authParams = array('digest' => isset($_SERVER['PHP_AUTH_DIGEST']) ? $_SERVER['PHP_AUTH_DIGEST'] : null); $authorization->setAuthorizationParams($authParams); $authorization->authorize(); }
/** * 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(); }