Files
pip/libs/http_server/pihttpserverprotected.cpp
T
andrey 4e1ab26124 Add HTTP Basic Auth and protected server modules
- PIHTTPServerBasicAuth: parse Authorization: Basic header, validate credentials via callback
- PIHTTPServerProtected: wrap any handler with auth check (basic or custom token)
- Integration tests for both modules (12 test cases)
2026-09-05 21:59:42 +03:00

13 lines
434 B
C++

#include "pihttpserverprotected.h"
bool PIHTTPServerProtected::registerProtectedPath(const PIString & path, PIHTTP::Method method, RequestFunction handler) {
RequestFunction h = std::move(handler);
RequestFunction guarded = [this, h](const PIHTTP::MessageConst & r) -> PIHTTP::MessageMutable {
if (!checkAccess(r)) return accessDeniedReply(r);
return h(r);
};
return registerPath(path, method, std::move(guarded));
}