File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ writing a model that tests user's local database credentials and do not want the
100100auth mode you would specify ` $this->set_auth_mode = "local"; ` to always force local authentication. Defaults to the
101101API'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
104108change logs found at Diagnostics > Backup & Restore > Config History. This defaults to "Made unknown change via API".
105109This is only necessary if your API model writes changes to the configuration.
Original file line number Diff line number Diff 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 )) {
Original file line number Diff line number Diff 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 );
Original file line number Diff line number Diff 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)
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments