From 05ff87d0b8f91674a30f8a3cf3a5d44563d308b9 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Fri, 13 Mar 2026 12:18:18 +0100 Subject: [PATCH] test: temp test --- README.md | 20 +++ main/CMakeLists.txt | 2 +- main/config.h | 8 +- main/html/index.html | 290 +++++++++++++++++++++++++++++++++++++++++-- main/web_server.c | 185 ++++++++++++++++++++++++--- 5 files changed, 477 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index a86092e..c9390ec 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ A Baseboard Management Controller (BMC) firmware for ESP32-S3 that provides remo - **Serial Console**: UART bridge with WebSocket support for remote console access - **Web Interface**: Modern HTML/CSS dashboard for easy management - **REST API**: Full REST API for programmatic control +- **HTTP Basic Authentication**: Secure access to web interface and API +- **OTA Updates**: Over-the-air firmware updates +- **System Logs**: View ESP32 logs via web interface or API ## Hardware Requirements @@ -78,6 +81,23 @@ idf.py -p /dev/ttyUSB0 monitor ## Configuration +### Authentication + +The web interface and API are protected by HTTP Basic Authentication. Default credentials: +- **Username**: `admin` +- **Password**: `admin` + +To change credentials, edit `main/config.h`: +```c +#define BMC_HTTP_AUTH_USERNAME "your_username" +#define BMC_HTTP_AUTH_PASSWORD "your_password" +``` + +To disable authentication: +```c +#define BMC_HTTP_AUTH_ENABLED 0 +``` + ### Network Settings By default, the firmware uses DHCP. To configure static IP: diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 9d3938d..d297823 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -8,7 +8,7 @@ idf_component_register(SRCS "main.c" INCLUDE_DIRS "." REQUIRES esp_driver_gpio esp_driver_uart esp_driver_spi esp_http_server esp_eth esp_netif lwip spi_flash nvs_flash log - esp_https_ota esp_http_client app_update) + esp_https_ota esp_http_client app_update mbedtls) # Embed HTML file target_add_binary_data(${COMPONENT_TARGET} "html/index.html" TEXT) diff --git a/main/config.h b/main/config.h index c4bc989..644fed6 100644 --- a/main/config.h +++ b/main/config.h @@ -27,7 +27,7 @@ // ============================================================================ // UART Serial Configuration // ============================================================================ -#define BMC_UART_NUM UART_NUM_1 +#define BMC_UART_NUM UART_NUM_0 #define BMC_UART_TX_GPIO GPIO_NUM_43 #define BMC_UART_RX_GPIO GPIO_NUM_44 #define BMC_UART_BAUD_RATE 115200 @@ -42,6 +42,12 @@ #define BMC_HTTP_MAX_CONN 17 #define BMC_HTTP_STACK_SIZE 8192 +// HTTP Basic Authentication +#define BMC_HTTP_AUTH_ENABLED 1 +#define BMC_HTTP_AUTH_USERNAME "admin" +#define BMC_HTTP_AUTH_PASSWORD "admin" +#define BMC_HTTP_AUTH_REALM "ESP32 BMC" + // ============================================================================ // GPIO Configuration // ============================================================================ diff --git a/main/html/index.html b/main/html/index.html index d092283..65f70b4 100644 --- a/main/html/index.html +++ b/main/html/index.html @@ -524,10 +524,109 @@ grid-template-columns: 1fr; } } + + /* Login Modal Styles */ + .login-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); + display: flex; + justify-content: center; + align-items: center; + z-index: 1000; + } + + .login-overlay.hidden { + display: none; + } + + .login-modal { + background: rgba(255, 255, 255, 0.1); + backdrop-filter: blur(10px); + border: 1px solid rgba(255, 255, 255, 0.2); + border-radius: 20px; + padding: 40px; + width: 100%; + max-width: 400px; + text-align: center; + } + + .login-modal h2 { + margin-bottom: 10px; + font-size: 1.8em; + } + + .login-modal p { + color: #aaa; + margin-bottom: 30px; + } + + .login-field { + margin-bottom: 20px; + text-align: left; + } + + .login-field label { + display: block; + margin-bottom: 8px; + color: #ccc; + font-size: 0.9em; + } + + .login-field input { + width: 100%; + padding: 12px 16px; + border: 1px solid rgba(255, 255, 255, 0.2); + border-radius: 8px; + background: rgba(255, 255, 255, 0.05); + color: #fff; + font-size: 1em; + outline: none; + transition: border-color 0.3s; + } + + .login-field input:focus { + border-color: #00d4ff; + } + + .login-btn { + width: 100%; + margin-top: 10px; + } + + .login-error { + color: #ff4444; + margin-top: 15px; + font-size: 0.9em; + min-height: 20px; + } -
+ + + +