![]() |
VR-Forces Developer's Guide
|
Functions | |
| std::shared_ptr < oatpp::web::protocol::http::outgoing::Response > | makeJsonResponse (const oatpp::web::protocol::http::Status &status, const Json::Value &body) |
| std::shared_ptr < oatpp::web::protocol::http::outgoing::Response > | makeJsonError (const oatpp::web::protocol::http::Status &status, const std::string &message) |
| bool | parseJsonBody (const std::shared_ptr< oatpp::web::protocol::http::incoming::Request > &request, Json::Value &out, std::string &errors) |
| std::string | extractSessionKey (const std::shared_ptr< oatpp::web::protocol::http::incoming::Request > &request) |
| std::shared_ptr < oatpp::web::protocol::http::outgoing::Response > | requirePermission (const std::shared_ptr< oatpp::web::protocol::http::incoming::Request > &request, const std::string &permission) |
| std::shared_ptr < oatpp::web::protocol::http::outgoing::Response > | requireValidSession (const std::shared_ptr< oatpp::web::protocol::http::incoming::Request > &request) |
Authentication helpers shared by REST controllers.
These are free functions (not a class) so they can be included in any controller translation unit without circular dependencies.
|
inline |
Builds a JSON response with the given HTTP status and body. The body is serialized to a compact JSON string.
Referenced by makeJsonError().
|
inline |
Builds a minimal JSON error response.
References makeJsonResponse(), and ImGui::Value().
Referenced by requirePermission(), and requireValidSession().
|
inline |
Parses the JSON body from a request. Returns false and sets errors if the body is missing, empty, or not valid JSON.
|
inline |
Extracts the Bearer token from the Authorization header. Returns an empty string if the header is absent or not in "Bearer <token>" form.
Referenced by requirePermission(), and requireValidSession().
|
inline |
Checks whether the request carries a valid session key with the required permission.
Returns nullptr if the check passes (caller continues normally). Returns a 401/403 response if the check fails (caller should return this response).
When access control is disabled, the check is always skipped and nullptr is returned.
References extractSessionKey(), DtWebServerSettings::getInstance(), DtSessionManager::getInstance(), makeJsonError(), and DtSessionManager::touchSession().
|
inline |
Checks only that the request carries a valid session key, with no specific permission required. Useful for endpoints accessible to any authenticated session.
Returns nullptr if the check passes. Returns a 401 response if the check fails.
When access control is disabled, the check is always skipped.
References extractSessionKey(), DtWebServerSettings::getInstance(), DtSessionManager::getInstance(), makeJsonError(), DtSessionManager::touchSession(), and DtSessionManager::validateSession().