Skip to content

Commit 11b72fb

Browse files
author
Jared Hendrickson
committed
Fixed bug that sometimes prevented the token server key from being generated
1 parent 87fcfc0 commit 11b72fb

5 files changed

Lines changed: 9 additions & 5 deletions

File tree

docs/CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ writing a model that tests user's local database credentials and do not want the
100100
auth mode you would specify `$this->set_auth_mode = "local";` to always force local authentication. Defaults to the
101101
API's configured auth mode in the /api/ webConfigurator page.
102102

103+
- `$this->set_read_mode` : Allows the read only API setting to be bypassed for this model. If you set this value to
104+
`true` the model will be allowed to use POST, PUT or DELETE methods even when the API is in read only mode. There is
105+
rarely a use case for this. Do not override this property unless absolutely needed.
106+
103107
- `$this->change_note` : Sets the description of the action that occurred via API. This value will be shown in the
104108
change logs found at Diagnostics > Backup & Restore > Config History. This defaults to "Made unknown change via API".
105109
This is only necessary if your API model writes changes to the configuration.

pfSense-pkg-API/files/etc/inc/api/framework/APIAuth.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ class APIAuth {
119119
$authorized = false;
120120
$client_config =& getUserEntry($this->username);;
121121
$this->privs = get_user_privileges($client_config);
122-
$read_only = array_key_exists("readonly", $this->api_config);
123122

124123
# If no require privileges were given, assume call is always authorized
125124
if (!empty($this->req_privs)) {

pfSense-pkg-API/files/etc/inc/api/framework/APIModel.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class APIModel {
3030
public $change_note;
3131
public $requires_auth;
3232
public $set_auth_mode;
33-
public $set_read_mode;
33+
public $bypass_read_mode;
3434

3535
public function __construct() {
3636
global $config;
@@ -40,7 +40,7 @@ class APIModel {
4040
$this->client = null;
4141
$this->requires_auth = true;
4242
$this->set_auth_mode = null;
43-
$this->set_read_mode = null;
43+
$this->bypass_read_mode = null;
4444
$this->change_note = "Made unknown change via API";
4545
$this->id = null;
4646
$this->validate_id = true;
@@ -97,7 +97,7 @@ class APIModel {
9797
}
9898

9999
private function check_authentication() {
100-
$this->client = new APIAuth($this->privileges, $this->set_auth_mode, $this->set_read_mode);
100+
$this->client = new APIAuth($this->privileges, $this->set_auth_mode, $this->bypass_read_mode);
101101
if ($this->requires_auth === true) {
102102
if (!$this->client->is_authenticated) {
103103
$this->errors[] = APIResponse\get(3);

pfSense-pkg-API/files/etc/inc/api/models/APIAccessTokenCreate.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class APIAccessTokenCreate extends APIModel {
2121
public function __construct() {
2222
parent::__construct();
2323
$this->set_auth_mode = "local";
24-
$this->set_read_mode = false;
24+
$this->bypass_read_mode = false;
2525
}
2626

2727
# Validate our API configurations auth mode (must be JWT)

pfSense-pkg-API/files/usr/local/www/api/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
$config["installedpackages"]["package"][$pkg_index]["conf"] = $api_config;
9999
$change_note = " Updated API settings";
100100
write_config(sprintf(gettext($change_note)));
101+
APITools\create_jwt_server_key();
101102
print_apply_result_box(0);
102103
}
103104

0 commit comments

Comments
 (0)