- 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)
13 lines
434 B
C++
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));
|
|
}
|
|
|