/** * Checks if the user is allowed to login using the current IP address * according to his BASE organization * * An adapter authorizes and if the end resultis boolean, string or array * it is converted into a \Zend_Auth_Result. * * @return mixed \Zend_Auth_Adapter_Interface|\Zend_Auth_Result|boolean|string|array */ protected function authorizeOrgIp() { //special case: project user should have no restriction if ($this->project->getSuperAdminName() == $this->getLoginName()) { return true; } //In unit test REMOTE_ADDR is not available and will return null $request = $this->getRequest(); // E.g. command line user if (!$request instanceof \Zend_Controller_Request_Http) { return true; } $remoteIp = $request->getServer('REMOTE_ADDR'); if ($this->util->isAllowedIP($remoteIp, $this->getBaseOrganization()->getAllowedIpRanges())) { return true; } return $this->_('You are not allowed to login from this location.'); }
public function testAllowedIPEmptyRange() { $this->assertTrue($this->object->isAllowedIP('127.0.0.1', '')); }