Codeigniter REST API 键不工作
Codeigniter REST API Keys not working
我正在使用 chriskacerguis/codeigniter-restserver 创建我的休息 api 服务器,我正在尝试启用 api 密钥,但他们的问题是即使我按照说明进行操作,我也无法使用任何密钥进行身份验证,即所有请求都会通过,即使他们在请求中没有 api 密钥 header。
这是我当前的配置
rest.php
$config['rest_keys_table'] = 'keys';
$config['rest_enable_keys'] = TRUE;
$config['rest_key_column'] = 'api_key';
$config['rest_limits_method'] = 'ROUTED_URL';
$config['rest_key_name'] = 'X-API-KEY';
我的 table 是使用以下 sql 查询创建的。
CREATE TABLE `keys` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`api_key` varchar(255) NOT NULL,
`level` int(2) NOT NULL,
`ignore_limits` tinyint(1) NOT NULL DEFAULT '0',
`is_private_key` tinyint(1) NOT NULL DEFAULT '0',
`ip_addresses` text,
`date_created` int(11) NOT NULL,
`api_key_activated` enum('yes','no') NOT NULL DEFAULT 'no'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `keys` (`id`, `user_id`, `api_key`, `level`, `ignore_limits`,
`is_private_key`, `ip_addresses`, `date_created`, `api_key_activated`)
VALUES
(1, 1, '1234', 10, 0, 0, NULL, 0, 'no'), (1, 1, '12345', 10, 0, 0, NULL, 0,
'yes')
问题是无论 what.I 在我的项目中启用了路由,请求都会通过,这会导致问题吗?
routes.php
$route['api/v1/foo/(:any)'] = 'Api_v1/foo/';
所以我只是一个使者,作为Chris,已经指出问题在REST_Controller.php,只需添加
$this->output->_display();
exit;
在 REST_Controller.php 的第 828 行,问题出在 codeigniter 3 的最后一个版本和 chriskacerguis/codeigniter-restserver 的最后一个版本。
我一直在与这一切作斗争 day.I 只是测试 Chris 的解决方案,一切似乎都运行良好。
使用您的群连接名称
$active_group = 'pdo_mysqli'; /*Local Conetion*/
我正在使用 chriskacerguis/codeigniter-restserver 创建我的休息 api 服务器,我正在尝试启用 api 密钥,但他们的问题是即使我按照说明进行操作,我也无法使用任何密钥进行身份验证,即所有请求都会通过,即使他们在请求中没有 api 密钥 header。
这是我当前的配置
rest.php
$config['rest_keys_table'] = 'keys';
$config['rest_enable_keys'] = TRUE;
$config['rest_key_column'] = 'api_key';
$config['rest_limits_method'] = 'ROUTED_URL';
$config['rest_key_name'] = 'X-API-KEY';
我的 table 是使用以下 sql 查询创建的。
CREATE TABLE `keys` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`api_key` varchar(255) NOT NULL,
`level` int(2) NOT NULL,
`ignore_limits` tinyint(1) NOT NULL DEFAULT '0',
`is_private_key` tinyint(1) NOT NULL DEFAULT '0',
`ip_addresses` text,
`date_created` int(11) NOT NULL,
`api_key_activated` enum('yes','no') NOT NULL DEFAULT 'no'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `keys` (`id`, `user_id`, `api_key`, `level`, `ignore_limits`,
`is_private_key`, `ip_addresses`, `date_created`, `api_key_activated`)
VALUES
(1, 1, '1234', 10, 0, 0, NULL, 0, 'no'), (1, 1, '12345', 10, 0, 0, NULL, 0,
'yes')
问题是无论 what.I 在我的项目中启用了路由,请求都会通过,这会导致问题吗?
routes.php
$route['api/v1/foo/(:any)'] = 'Api_v1/foo/';
所以我只是一个使者,作为Chris,已经指出问题在REST_Controller.php,只需添加
$this->output->_display();
exit;
在 REST_Controller.php 的第 828 行,问题出在 codeigniter 3 的最后一个版本和 chriskacerguis/codeigniter-restserver 的最后一个版本。
我一直在与这一切作斗争 day.I 只是测试 Chris 的解决方案,一切似乎都运行良好。
使用您的群连接名称
$active_group = 'pdo_mysqli'; /*Local Conetion*/