UniFi-API-client: Unable to delete radius account.
I am unable to delete radius account.
UDM Pro v. 1.8.4 UniFi Network v. 6.0.43 (Build: atag_6.0.43_14348)
List radius accounts:
-------URL & PAYLOAD---------
https://10.28.0.167/proxy/network/api/s/default/rest/account
empty payload
----------RESPONSE-----------
{"meta":{"rc":"ok"},"data":[{"_id":"5fefc567c8028604215ed7cf","name":"john.doe","x_password":"secret-password","tunnel_type":13,"tunnel_medium_type":6,"vlan":2810,"site_id":"12345679123456789123456"}]}
-----------------------------
</pre>
[
{
"_id": "5fefc567c8028604215ed7cf",
"name": "john.doe",
"x_password": "secret-password",
"tunnel_type": 13,
"tunnel_medium_type": 6,
"vlan": 2810,
"site_id": "12345679123456789123456"
}
]
Trying to delete that account:
<pre>
---------cURL INFO-----------
Array
(
[url] => https://10.28.0.167/proxy/network/api/s/default/rest/account/5fefc567c8028604215ed7cf
[content_type] => text/plain; charset=utf-8
[http_code] => 404
[header_size] => 473
[request_size] => 426
[filetime] => -1
[ssl_verify_result] => 18
[redirect_count] => 0
[total_time] => 0.039487
[namelookup_time] => 1.8E-5
[connect_time] => 0.000208
[pretransfer_time] => 0.02417
[size_upload] => 0
[size_download] => 9
[speed_download] => 227
[speed_upload] => 0
[download_content_length] => 9
[upload_content_length] => -1
[starttransfer_time] => 0.039404
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 10.28.0.167
[certinfo] => Array
(
)
[primary_port] => 443
[local_ip] => 10.28.0.51
[local_port] => 54870
)
-------URL & PAYLOAD---------
https://10.28.0.167/proxy/network/api/s/default/rest/account/5fefc567c8028604215ed7cf
empty payload
----------RESPONSE-----------
Not Found
-----------------------------
</pre>
PHP Notice: JSON decode error: Syntax error, malformed JSON in /path/to/git/UniFi-API-client/src/Client.php on line 3606
account deletetion FAILED ...
Used code:
/**
* initialize the UniFi API connection class and log in to the controller and do our thing
*/
$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion);
$set_debug_mode = $unifi_connection->set_debug($debug);
$loginresults = $unifi_connection->login();
if ($loginresults === 400) {
print "UniFi controller login failure, please check your credentials in config.php.\n";
exit(-1);
}
$data = $unifi_connection->list_radius_accounts();
/**
* provide feedback in json format
*/
echo json_encode($data, JSON_PRETTY_PRINT);
$account_id = '5fefc567c8028604215ed7cf';
if ($unifi_connection->delete_radius_account($account_id)) {
echo "\naccount deletion succeeds ...\n";
}
else {
echo "\naccount deletetion FAILED ...\n";
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16
@paciks Can you see whether this version of the
exec_curl
function/method fixes the issue?I am not an expert but I was able to reproduce “NOT FOUND” response playing with BurpSuite, to do that I had to modify
x-csrf-token
in repeated request:And with the correct value of
x-csfr-token
:Modified value:
x-csrf-token: 8ba0c82d-f803-4c89-b8ea-67a31a906b6c
Correct value:x-csrf-token: 8ba0c82d-f803-4c89-b8ea-67a31a906b6b
When I was trying to DELETE already (deleted above) non-existed account the response was:
I hope it is helpful.