/*
|--------------------------------------------------------------------------
| REST Method Access Control
|--------------------------------------------------------------------------
| When set to TRUE, the REST API will check the access table to see if
| the API key can access that controller. 'rest_enable_keys' must be enabled
| to use this
|
| Default table schema:
| CREATE TABLE `access` (
| `id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
| `key` VARCHAR(40) NOT NULL DEFAULT '',
| `controller` VARCHAR(50) NOT NULL DEFAULT '',
| `date_created` DATETIME DEFAULT NULL,
| `date_modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
*/
$config['rest_enable_access'] = FALSE;
答案 0 :(得分:0)
1)在BD中创建一个名为“ci_api_access”的表:
CREATE TABLE
ci_api_access (
|
ID为INT(11) unsigned NOT NULL AUTO_INCREMENT,
|
键VARCHAR(40) NOT NULL DEFAULT '',
|
控制器VARCHAR(50) NOT NULL DEFAULT '',
|
DATE_CREATED DATETIME DEFAULT NULL,
|
DATE_MODIFIED TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
| PRIMARY KEY (
ID为)
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2 将'rest_enable_access'设置为TRUE:
$config['rest_enable_access'] = TRUE;
3 在表 ci_api_access 中插入任何值:
(样品)
INSERT INTO ci_api_access id, key, controller, date_created, date_modified
VALUES ('', 'YOUR_KEY', 'YOUR_CONTROLLER_NAME', '2016-04-02 00:00:00', '2016-04-02 00:00:00');
观看本教程,了解如何保护您的API: https://www.youtube.com/watch?v=z1xGdMONnOE
REST访问控制方法控制器名称存在问题,您需要按照以下说明进行修复: https://github.com/chriskacerguis/codeigniter-restserver/issues/268