- Added basic auth to restart and LED

- GUI: show IP address instead of hostname.local
This commit is contained in:
Rene Zeldenthuis
2022-11-04 14:02:35 +01:00
parent b19d1edb6d
commit e95a7b3aa2
4 changed files with 33 additions and 13 deletions

View File

@@ -172,26 +172,32 @@ This link can be opened with for example [VLC](https://www.videolan.org/vlc/).
## API
There is a minimum API present to perform some tasks using HTTP requests.
There is a minimum API present to perform some tasks using HTTP requests. For some requests authentication is required.
The authentication used is basic authentication. The user is always admin and the password the access point key.\
If using a browser, remember that the authentication is stored in the browser session so needs to be entered only once.
The URLs are below:
### GET: /restart
Calling this URL will restart the device.
Calling this URL will restart the device. Authentication is required.
### GET: /config
Calling this URL will start the form for configuring the device in the browser.
Calling this URL will start the form for configuring the device in the browser. Authentication is required.
### GET: /snapshot
Calling this URL will return a JPEG snapshot of the camera in the browser.
### GET: /flash?v={value}
This request can also be used (for example using cURL) to save the snapshot to a file.
Calling this URL will set the intensity of the flash LED.
The values must for {value} must be between 0 and 255.
If no v parameter is present, it will be set to the value of the configuration.
### GET: /flash?v={intensity}
Calling this URL will set the intensity of the flash LED. Authentication is required.
The parameter v for the intensity must be between 0 (off) and 255 (max).
If no v parameter is present, it will be set to the value of the flash LED intensity from configuration.
## Issues / Nice to know

View File

@@ -182,26 +182,27 @@
<span>
The camera RTSP stream can be found at:
<a
href="rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1">rtsp://{{HostName}}:{{RtspPort}}/mjpeg/1</a>
href="rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1">rtsp://{{IpV4}}:{{RtspPort}}/mjpeg/1</a>
</span>
</div>
<div class="row">
<span>
A snapshot of the camera can be found at:
<a href="http://{{IpV4}}/snapshot">http://{{HostName}}/snapshot</a>
<a href="http://{{IpV4}}/snapshot">http://{{IpV4}}/snapshot</a>
</span>
</div>
<div class="row">
<span>
The intensity of the flash led (0-255) can be controlled using:
<a href="http://{{IpV4}}/flash?v=0">http://{{HostName}}/flash?v=value</a>.
If no value is present, the configuration value is used.
<a href="http://{{IpV4}}/flash?v=0">http://{{IpV4}}/flash?v=value</a>.
Authentication is required and if no value is present, the configuration value is used.
</span>
</div>
<div class="row">
<span>
Restarting the camera can be done using:
<a href="http://{{IpV4}}/restart">http://{{HostName}}/restart</a>
<a href="http://{{IpV4}}/restart">http://{{IpV4}}/restart</a>.
Authentication is required.
</span>
</div>
</div>

File diff suppressed because one or more lines are too long

View File

@@ -122,6 +122,12 @@ void handle_restart()
{
log_v("Handle restart");
if (!web_server.authenticate("admin", iotWebConf.getApPasswordParameter()->valueBuffer))
{
web_server.requestAuthentication();
return;
}
const moustache_variable_t substitutions[] = {
{"AppTitle", APP_TITLE},
{"AppVersion", APP_VERSION},
@@ -161,6 +167,13 @@ void handle_snapshot()
void handle_flash()
{
log_v("handle_flash");
if (!web_server.authenticate("admin", iotWebConf.getApPasswordParameter()->valueBuffer))
{
web_server.requestAuthentication();
return;
}
// If no value present, use value from config
auto value = web_server.hasArg("v") ? web_server.arg("v") : flash_led_intensity_val;
// If conversion fails, v = 0