30 lines
1.6 KiB
C
30 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-3.0-only */
|
|
#pragma once
|
|
#include "esp_http_server.h"
|
|
#include "web_session_store.h"
|
|
|
|
esp_err_t web_cookie_auth_start(void);
|
|
void web_cookie_auth_stop(void);
|
|
typedef struct {
|
|
uint32_t login_attempts, login_failures, throttled, capacity_rejections;
|
|
uint32_t security_rejections, logouts, active_challenges;
|
|
bool ready;
|
|
} web_cookie_auth_snapshot_t;
|
|
void web_cookie_auth_get_snapshot(web_cookie_auth_snapshot_t *snapshot);
|
|
void web_cookie_auth_clear_counters(void);
|
|
/* HTTPD handler context, before body reads/responses; all pointers required.
|
|
* Admission requires ESP_OK AND allowed=true: a sent denial can return ESP_OK.
|
|
* mutation selects POST plus CSRF; otherwise GET. mutation/upgrade require Origin.
|
|
* This variant rejects bodies. Role checks remain with the caller; a successful
|
|
* view is not a lease for later actions. Wipe the view after use, even on denial. */
|
|
esp_err_t web_cookie_auth_require(httpd_req_t *request, bool mutation,
|
|
bool upgrade, web_session_view_t *view,
|
|
bool *allowed);
|
|
esp_err_t web_cookie_auth_handler(httpd_req_t *request);
|
|
/* Same mutation policy for a bounded raw body; caller validates content type. */
|
|
esp_err_t web_cookie_auth_require_body(httpd_req_t *request, size_t body_limit,
|
|
web_session_view_t *view, bool *allowed);
|
|
/* Same mutation policy, allowing a bounded body; caller validates JSON/content type. */
|
|
esp_err_t web_cookie_auth_require_json(httpd_req_t *request, size_t body_limit,
|
|
web_session_view_t *view, bool *allowed);
|