From f86f372484717d029dadbdcd04fbeaf590ee9f87 Mon Sep 17 00:00:00 2001 From: Elmar Ludwig Date: Tue, 17 Dec 2024 20:42:47 +0000 Subject: remove obsolete files, fixes #5039 Closes #5039 Merge request studip/studip!3774 --- app/views/admin/webservice_access/index.php | 105 -------------------- app/views/admin/webservice_access/test.php | 52 ---------- lib/models/WebserviceAccessRule.php | 149 ---------------------------- 3 files changed, 306 deletions(-) delete mode 100644 app/views/admin/webservice_access/index.php delete mode 100644 app/views/admin/webservice_access/test.php delete mode 100644 lib/models/WebserviceAccessRule.php diff --git a/app/views/admin/webservice_access/index.php b/app/views/admin/webservice_access/index.php deleted file mode 100644 index 86367aa..0000000 --- a/app/views/admin/webservice_access/index.php +++ /dev/null @@ -1,105 +0,0 @@ - -

-
- - - - - - - - - - - - id) :?> - - - - - - - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - - - asInput([ - 'title' => _('Änderungen speichern'), - 'type' => 'image', - 'class' => 'middle', - 'name' => 'ok', - ]) ?> - asInput([ - 'title' => _('Abbrechen'), - 'type' => 'image', - 'class' => 'middle', - 'name' => 'cancel', - ]) ?> - - api_key) ?> - - method) ?> - - ip_range) ?> - - type) ?> - - - asImg(['title' => _('bearbeiten')]) ?> - - - asImg(['title' => _('löschen')]) ?> - -
-
-addLink( - _('Regeln testen'), - $controller->url_for('admin/webservice_access/test'), - Icon::create('unit-test') -); -$actions->addLink( - _('Neue Zugriffsregel anlegen'), - $controller->url_for('admin/webservice_access/new'), - Icon::create('add') -); - -$sidebar->addWidget($actions); diff --git a/app/views/admin/webservice_access/test.php b/app/views/admin/webservice_access/test.php deleted file mode 100644 index 0b05dce..0000000 --- a/app/views/admin/webservice_access/test.php +++ /dev/null @@ -1,52 +0,0 @@ - -
- -
- - - - - - - - - -
- -
- _('Test starten')])?> - url_for('admin/webservice_access'), ['title' => _('Test abbrechen')])?> -
-
- -addLink( - _('Liste der Zugriffsregeln'), - $controller->url_for('admin/webservice_access'), - Icon::create('add') -); -$actions->addLink( - _('Neue Zugriffsregel anlegen'), - $controller->url_for('admin/webservice_access/new'), - Icon::create('add') -); - -$sidebar->addWidget($actions); diff --git a/lib/models/WebserviceAccessRule.php b/lib/models/WebserviceAccessRule.php deleted file mode 100644 index 857830a..0000000 --- a/lib/models/WebserviceAccessRule.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @copyright 2011 Stud.IP Core-Group - * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 - * @category Stud.IP - * - * @property string $api_key database column - * @property string $method database column - * @property CSVArrayObject $ip_range database column - * @property string $type database column - * @property int $id database column - * @property int|null $mkdate database column - * @property int|null $chdate database column - */ -class WebserviceAccessRule extends SimpleORMap -{ - protected static function configure($config = []) - { - $config['db_table'] = 'webservice_access_rules'; - $config['serialized_fields']['ip_range'] = CSVArrayObject::class; - parent::configure($config); - } - - /** - * returns all rules for an given api key - * - * @param string $api_key - * @return array of WebserviceAccessRule objects - */ - static function findByApiKey($api_key) - { - return self::findByapi_key($api_key, " ORDER BY type"); - } - - /** - * returns all rules in db sorted by api key - * - * @return array of WebserviceAccessRule objects - */ - static function findAll() - { - return self::findBySQL("1 ORDER BY api_key, type"); - } - - /** - * Checks for given api key, methodname and IP Address if access - * is granted or not - * - * @param string $api_key an api key - * @param string $method a name of an webservice method - * @param string $ip an IP Address - * @return boolean returns true if access fpr given params is allowed - */ - static function checkAccess($api_key, $method, $ip) - { - $rules = self::findByApiKey($api_key); - $access = false; - foreach ($rules as $rule) { - if ($rule->type == 'allow' - && $rule->checkIpInRange($ip) - && $rule->checkMethodName($method)) { - $access = true; - } - if ($rule->type == 'deny' - && $rule->checkIpInRange($ip) - && $rule->checkMethodName($method)) { - $access = false; - } - } - return $access; - } - - /** - * checks, if a given IP Address is in the range specified - * for this rule. If there is no specified range, it returns true - * - * @param string $check_ip an IP Address - * @return boolean true if given Address is in specified range - */ - function checkIpInRange($check_ip) - { - $ip_addr = inet_pton($check_ip); - - if (!count($this->ip_range)) { - return true; - } - foreach ($this->ip_range as $range) { - if (strpos($range, '/') !== false) { - list($range, $bits) = explode('/', $range); - $range = inet_pton($range) ?: ''; - $mask = str_repeat(chr(0), strlen($range)); - - for ($i = 0; $i < strlen($mask); ++$i) { - if ($bits >= 8) { - $bits -= 8; - } else { - $mask[$i] = chr((1 << 8 - $bits) - 1); - $bits = 0; - } - } - - $ip_start = $range & ~$mask; - $ip_end = $range | $mask; - } else { - $ip_start = inet_pton($range); - $ip_end = inet_pton($range); - } - - if (strcmp($ip_start, $ip_addr) <= 0 && strcmp($ip_addr, $ip_end) <= 0) { - return true; - } - } - return false; - } - - /** - * checks, if the specified method name for this rule - * is part of the given one. - * If there is no specified method name, it returns true - * - * - * @param string $method a webservice method name - * @return boolean true if given name matches the specified - */ - function checkMethodName($method) - { - return ($method && (!$this->method || mb_strpos($method, $this->method) !== false)); - } -} -- cgit v1.0