4
我正在使用chriskacerguis/codeigniter-restserver創建我的休息api服務器,我試圖啓用api密鑰,但他們的問題是,即使我按照說明操作,我無法使用任何密鑰進行身份驗證,即全部即使請求中沒有api密鑰標頭,請求也會通過。Codeigniter REST API密鑰不能正常工作
這是我目前的配置
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';
我的表是使用下面的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')
問題是無論如何,請求都會經過。我在我的項目中啓用了路由,是否會導致問題?
routes.php文件
$route['api/v1/foo/(:any)'] = 'Api_v1/foo/$1';