Bind Serial Transports To Web Sessions
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "esp_http_server.h"
|
||||
#include "session_broker.h"
|
||||
#include "user_database.h"
|
||||
#include "web_session_store.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -98,20 +99,24 @@ esp_err_t web_serial_transport_attach_server(httpd_handle_t server);
|
||||
esp_err_t web_serial_transport_detach_server(httpd_handle_t server);
|
||||
|
||||
/*
|
||||
* Mint a one-time bearer ticket bound to a current authenticated principal. The
|
||||
* Mint a one-time bearer ticket bound to a current authenticated principal and
|
||||
* originating web-session ID (zero only for the shipped Basic path). The
|
||||
* principal is copied; the output is exactly 32 Base64URL characters plus a
|
||||
* terminator and expires after 30 monotonic seconds. Never log or persist it.
|
||||
*/
|
||||
esp_err_t web_serial_transport_mint_ticket(const user_principal_t *principal,
|
||||
web_session_id_t web_session_id,
|
||||
char *ticket, size_t capacity);
|
||||
|
||||
/*
|
||||
* Convenience POST response helper for /api/ws-ticket. Authentication is
|
||||
* intentionally outside this module: pass the principal returned by successful
|
||||
* Basic authentication. Register it as HTTP_POST, not as a public handler.
|
||||
* authentication, and its session ID (zero for Basic). Cookie callers must also
|
||||
* enforce CSRF/Origin policy. Register as HTTP_POST, not as a public handler.
|
||||
*/
|
||||
esp_err_t web_serial_transport_handle_authenticated_ticket_request(
|
||||
httpd_req_t *request, const user_principal_t *principal);
|
||||
httpd_req_t *request, const user_principal_t *principal,
|
||||
web_session_id_t web_session_id);
|
||||
|
||||
/*
|
||||
* Handler for /ws/serial. Register as HTTP_GET with is_websocket=true and
|
||||
@@ -119,6 +124,13 @@ esp_err_t web_serial_transport_handle_authenticated_ticket_request(
|
||||
* ticket; later invocations process one complete data frame.
|
||||
*/
|
||||
esp_err_t web_serial_transport_ws_handler(httpd_req_t *request);
|
||||
/* Trusted future cookie-authorized upgrade caller; must validate cookie/Origin
|
||||
* first. Zero identifies only the shipped Basic path, never a cookie fallback. */
|
||||
esp_err_t web_serial_transport_session_ws_handler(httpd_req_t *request,
|
||||
web_session_id_t web_session_id);
|
||||
/* Invalidates the store first, then marks only matching tickets/slots for owner
|
||||
* cleanup. Safe to repeat after either store or transport slot reuse. */
|
||||
esp_err_t web_serial_transport_revoke_web_session(web_session_id_t id);
|
||||
|
||||
esp_err_t web_serial_transport_get_snapshot(
|
||||
web_serial_transport_snapshot_t *snapshot);
|
||||
@@ -126,7 +138,9 @@ esp_err_t web_serial_transport_get_snapshot(
|
||||
/* Clearing counters does not alter tickets, sessions, ownership, or queued data. */
|
||||
esp_err_t web_serial_transport_clear_counters(void);
|
||||
|
||||
/* Invalidate tickets/sessions for one account, or all authenticated sessions. */
|
||||
/* Invalidate cookie records and tickets/sockets for one username (also after
|
||||
* deletion), or all accounts. Store invalidation occurs even if serial init
|
||||
* failed; these do not touch the HTTPD-owned Basic cache, which rechecks DB. */
|
||||
esp_err_t web_serial_transport_revoke_user(const uint8_t *username,
|
||||
size_t username_length);
|
||||
esp_err_t web_serial_transport_revoke_sessions(void);
|
||||
|
||||
Reference in New Issue
Block a user