在构造函数的rest config中设置白名单ip

时间:2018-07-18 06:44:40

标签: php rest codeigniter-3 codeigniter-restserver

将CI3与chriskacerguis restserver一起使用。只允许访问控制器到特定的IP地址
在配置文件中,启用了rest_ip_whitelist_white,rest_ip_whitelist可用,但适用于整个项目
我的代码

defined('BASEPATH') OR exit('No direct script access allowed');
require APPPATH . 'libraries/REST_Controller.php';
class Datasink extends REST_Controller {

    function __construct()
        {
            parent::__construct();
            $this->methods['users_get']['limit'] = 500;
            $this->methods['users_post']['limit'] = 100;
            $this->methods['users_delete']['limit'] = 50;
            $this->config->load('rest');        
            $this->config->set_item('rest_ip_whitelist_enabled',TRUE);
            $this->config->set_item('rest_ip_whitelist','XXX.XXX.XXX.XXX');
        }
}

先谢谢了。

0 个答案:

没有答案