Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Web Interface and REST auth #3436

Merged
merged 7 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
## [16.0.0-RC6] - 2024-xx-xx

For a full list of changes see [Full list of changes](https://github.com/jomjol/AI-on-the-edge-device/compare/v15.7.0...v16.0.0)

#### Known issues
Please check the [issues](https://github.com/jomjol/AI-on-the-edge-device/issues) and
[discussions](https://github.com/jomjol/AI-on-the-edge-device/discussions) before reporting a new issue.

#### Core Changes
Only changes since RC5 are listed:
- Added basic authentification of the Web Interface and the REST API, see https://jomjol.github.io/AI-on-the-edge-device-docs/Password-Protection/
- xxx

**:warning: Please check your Homeassistant instance to make sure it is handled correctly!**

#### Bug Fixes
Only changes since RC5 are listed:
- xxx

## [16.0.0-RC5] - 2024-12-05

For a full list of changes see [Full list of changes](https://github.com/jomjol/AI-on-the-edge-device/compare/v15.7.0...v16.0.0)
Expand All @@ -22,11 +41,11 @@ Only changes since RC4 are listed:
**:warning: Please check your Homeassistant instance to make sure it is handled correctly!**

#### Bug Fixes
Only changes since RC3 are listed:
Only changes since RC4 are listed:
- Added fix for ledintensity (#3418)
- Added fix for OV2640 brightness contrast saturation (#3417)
- Added fix for 'AnalogToDigitTransitionStart' always using 9.2 regardless of the configured value (#3393)
- Addef fix for HA menu entry (#3342)
- Added fix for HA menu entry (#3342)


## [16.0.0-RC4] - 2024-10-06
Expand Down
3 changes: 2 additions & 1 deletion code/components/jomjol_controlGPIO/server_GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "server_mqtt.h"
#endif //ENABLE_MQTT

#include "basic_auth.h"

static const char *TAG = "GPIO";
QueueHandle_t gpio_queue_handle = NULL;
Expand Down Expand Up @@ -458,7 +459,7 @@ void GpioHandler::registerGpioUri()
httpd_uri_t camuri = { };
camuri.method = HTTP_GET;
camuri.uri = "/GPIO";
camuri.handler = callHandleHttpRequest;
camuri.handler = APPLY_BASIC_AUTH_FILTER(callHandleHttpRequest);
camuri.user_ctx = (void*)this;
httpd_register_uri_handler(_httpServer, &camuri);
}
Expand Down
12 changes: 7 additions & 5 deletions code/components/jomjol_controlcamera/server_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "ClassLogFile.h"
#include "esp_log.h"

#include "basic_auth.h"

#include "../../include/defines.h"

static const char *TAG = "server_cam";
Expand Down Expand Up @@ -280,27 +282,27 @@ void register_server_camera_uri(httpd_handle_t server)
camuri.method = HTTP_GET;

camuri.uri = "/lighton";
camuri.handler = handler_lightOn;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_lightOn);
camuri.user_ctx = (void *)"Light On";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/lightoff";
camuri.handler = handler_lightOff;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_lightOff);
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/capture";
camuri.handler = handler_capture;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_capture);
camuri.user_ctx = NULL;
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/capture_with_flashlight";
camuri.handler = handler_capture_with_light;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_capture_with_light);
camuri.user_ctx = NULL;
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/save";
camuri.handler = handler_capture_save_to_file;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_capture_save_to_file);
camuri.user_ctx = NULL;
httpd_register_uri_handler(server, &camuri);
}
15 changes: 8 additions & 7 deletions code/components/jomjol_fileserver_ota/server_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern "C" {

#include "Helper.h"
#include "miniz.h"
#include "basic_auth.h"

static const char *TAG = "OTA FILE";

Expand Down Expand Up @@ -1174,7 +1175,7 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
httpd_uri_t file_download = {
.uri = "/fileserver*", // Match all URIs of type /path/to/file
.method = HTTP_GET,
.handler = download_get_handler,
.handler = APPLY_BASIC_AUTH_FILTER(download_get_handler),
.user_ctx = server_data // Pass server data as context
};
httpd_register_uri_handler(server, &file_download);
Expand All @@ -1183,7 +1184,7 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
httpd_uri_t file_datafileact = {
.uri = "/datafileact", // Match all URIs of type /path/to/file
.method = HTTP_GET,
.handler = datafileact_get_full_handler,
.handler = APPLY_BASIC_AUTH_FILTER(datafileact_get_full_handler),
.user_ctx = server_data // Pass server data as context
};
httpd_register_uri_handler(server, &file_datafileact);
Expand All @@ -1192,15 +1193,15 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
httpd_uri_t file_datafile_last_part_handle = {
.uri = "/data", // Match all URIs of type /path/to/file
.method = HTTP_GET,
.handler = datafileact_get_last_part_handler,
.handler = APPLY_BASIC_AUTH_FILTER(datafileact_get_last_part_handler),
.user_ctx = server_data // Pass server data as context
};
httpd_register_uri_handler(server, &file_datafile_last_part_handle);

httpd_uri_t file_logfileact = {
.uri = "/logfileact", // Match all URIs of type /path/to/file
.method = HTTP_GET,
.handler = logfileact_get_full_handler,
.handler = APPLY_BASIC_AUTH_FILTER(logfileact_get_full_handler),
.user_ctx = server_data // Pass server data as context
};
httpd_register_uri_handler(server, &file_logfileact);
Expand All @@ -1209,7 +1210,7 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
httpd_uri_t file_logfile_last_part_handle = {
.uri = "/log", // Match all URIs of type /path/to/file
.method = HTTP_GET,
.handler = logfileact_get_last_part_handler,
.handler = APPLY_BASIC_AUTH_FILTER(logfileact_get_last_part_handler),
.user_ctx = server_data // Pass server data as context
};
httpd_register_uri_handler(server, &file_logfile_last_part_handle);
Expand All @@ -1219,7 +1220,7 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
httpd_uri_t file_upload = {
.uri = "/upload/*", // Match all URIs of type /upload/path/to/file
.method = HTTP_POST,
.handler = upload_post_handler,
.handler = APPLY_BASIC_AUTH_FILTER(upload_post_handler),
.user_ctx = server_data // Pass server data as context
};
httpd_register_uri_handler(server, &file_upload);
Expand All @@ -1228,7 +1229,7 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
httpd_uri_t file_delete = {
.uri = "/delete/*", // Match all URIs of type /delete/path/to/file
.method = HTTP_POST,
.handler = delete_post_handler,
.handler = APPLY_BASIC_AUTH_FILTER(delete_post_handler),
.user_ctx = server_data // Pass server data as context
};
httpd_register_uri_handler(server, &file_delete);
Expand Down
5 changes: 3 additions & 2 deletions code/components/jomjol_fileserver_ota/server_ota.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include "Helper.h"
#include "statusled.h"
#include "basic_auth.h"
#include "../../include/defines.h"

/*an ota data write buffer ready to write to the flash*/
Expand Down Expand Up @@ -690,13 +691,13 @@ void register_server_ota_sdcard_uri(httpd_handle_t server)
httpd_uri_t camuri = { };
camuri.method = HTTP_GET;
camuri.uri = "/ota";
camuri.handler = handler_ota_update;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_ota_update);
camuri.user_ctx = (void*) "Do OTA";
httpd_register_uri_handler(server, &camuri);

camuri.method = HTTP_GET;
camuri.uri = "/reboot";
camuri.handler = handler_reboot;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_reboot);
camuri.user_ctx = (void*) "Reboot";
httpd_register_uri_handler(server, &camuri);

Expand Down
1 change: 1 addition & 0 deletions code/components/jomjol_flowcontroll/ClassFlowControll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern "C" {

#include "server_help.h"
#include "MainFlowControl.h"
#include "basic_auth.h"
#include "../../include/defines.h"

static const char* TAG = "FLOWCTRL";
Expand Down
41 changes: 21 additions & 20 deletions code/components/jomjol_flowcontroll/MainFlowControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "read_wlanini.h"
#include "connect_wlan.h"
#include "psram.h"
#include "basic_auth.h"

// support IDF 5.x
#ifndef portTICK_RATE_MS
Expand Down Expand Up @@ -1782,108 +1783,108 @@ void register_server_main_flow_task_uri(httpd_handle_t server)
camuri.method = HTTP_GET;

camuri.uri = "/doinit";
camuri.handler = handler_init;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_init);
camuri.user_ctx = (void *)"Light On";
httpd_register_uri_handler(server, &camuri);

// Legacy API => New: "/setPreValue"
camuri.uri = "/setPreValue.html";
camuri.handler = handler_prevalue;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_prevalue);
camuri.user_ctx = (void *)"Prevalue";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/setPreValue";
camuri.handler = handler_prevalue;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_prevalue);
camuri.user_ctx = (void *)"Prevalue";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/flow_start";
camuri.handler = handler_flow_start;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_flow_start);
camuri.user_ctx = (void *)"Flow Start";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/statusflow.html";
camuri.handler = handler_statusflow;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_statusflow);
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/statusflow";
camuri.handler = handler_statusflow;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_statusflow);
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);

// Legacy API => New: "/cpu_temperature"
camuri.uri = "/cputemp.html";
camuri.handler = handler_cputemp;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_cputemp);
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/cpu_temperature";
camuri.handler = handler_cputemp;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_cputemp);
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);

// Legacy API => New: "/rssi"
camuri.uri = "/rssi.html";
camuri.handler = handler_rssi;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_rssi);
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/rssi";
camuri.handler = handler_rssi;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_rssi);
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/date";
camuri.handler = handler_current_date;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_current_date);
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/uptime";
camuri.handler = handler_uptime;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_uptime);
camuri.user_ctx = (void *)"Light Off";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/editflow";
camuri.handler = handler_editflow;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_editflow);
camuri.user_ctx = (void *)"EditFlow";
httpd_register_uri_handler(server, &camuri);

// Legacy API => New: "/value"
camuri.uri = "/value.html";
camuri.handler = handler_wasserzaehler;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_wasserzaehler);
camuri.user_ctx = (void *)"Value";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/value";
camuri.handler = handler_wasserzaehler;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_wasserzaehler);
camuri.user_ctx = (void *)"Value";
httpd_register_uri_handler(server, &camuri);

// Legacy API => New: "/value"
camuri.uri = "/wasserzaehler.html";
camuri.handler = handler_wasserzaehler;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_wasserzaehler);
camuri.user_ctx = (void *)"Wasserzaehler";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/json";
camuri.handler = handler_json;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_json);
camuri.user_ctx = (void *)"JSON";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/heap";
camuri.handler = handler_get_heap;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_get_heap);
camuri.user_ctx = (void *)"Heap";
httpd_register_uri_handler(server, &camuri);

camuri.uri = "/stream";
camuri.handler = handler_stream;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_stream);
camuri.user_ctx = (void *)"stream";
httpd_register_uri_handler(server, &camuri);

/** will handle metrics requests */
camuri.uri = "/metrics";
camuri.handler = handler_openmetrics;
camuri.handler = APPLY_BASIC_AUTH_FILTER(handler_openmetrics);
camuri.user_ctx = (void *)"metrics";
httpd_register_uri_handler(server, &camuri);

Expand Down
3 changes: 2 additions & 1 deletion code/components/jomjol_mqtt/server_mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "interface_mqtt.h"
#include "time_sntp.h"
#include "../../include/defines.h"
#include "basic_auth.h"



Expand Down Expand Up @@ -347,7 +348,7 @@ void register_server_mqtt_uri(httpd_handle_t server) {
uri.method = HTTP_GET;

uri.uri = "/mqtt_publish_discovery";
uri.handler = scheduleSendingDiscovery_and_static_Topics;
uri.handler = APPLY_BASIC_AUTH_FILTER(scheduleSendingDiscovery_and_static_Topics);
uri.user_ctx = (void*) "";
httpd_register_uri_handler(server, &uri);
}
Expand Down
Loading
Loading