Skip to content

Commit d0cdf6e

Browse files
committed
For cases where you want a particular api-key to have access to all controllers, it is better to have a flag to indicate that instead of having a row for each controller.
1 parent 5ffd118 commit d0cdf6e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

application/config/rest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@
417417
| CREATE TABLE `access` (
418418
| `id` INT(11) unsigned NOT NULL AUTO_INCREMENT,
419419
| `key` VARCHAR(40) NOT NULL DEFAULT '',
420+
| `all_access` TINYINT(1) NOT NULL DEFAULT '0',
420421
| `controller` VARCHAR(50) NOT NULL DEFAULT '',
421422
| `date_created` DATETIME DEFAULT NULL,
422423
| `date_modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

application/libraries/REST_Controller.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,16 @@ protected function _check_access()
21532153
{
21542154
return TRUE;
21552155
}
2156+
2157+
//check if the key has all_access
2158+
$accessRow = $this->rest->db
2159+
->where('key', $this->rest->key)
2160+
->get($this->config->item('rest_access_table'))->row_array();
2161+
2162+
if (!empty($accessRow) && !empty($accessRow['all_access']))
2163+
{
2164+
return TRUE;
2165+
}
21562166

21572167
// Fetch controller based on path and controller name
21582168
$controller = implode(

0 commit comments

Comments
 (0)