VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
DtAuthHelpers Namespace Reference

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)
 

Detailed Description

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.

Function Documentation

std::shared_ptr<oatpp::web::protocol::http::outgoing::Response> DtAuthHelpers::makeJsonResponse ( const oatpp::web::protocol::http::Status &  status,
const Json::Value &  body 
)
inline

Builds a JSON response with the given HTTP status and body. The body is serialized to a compact JSON string.

Referenced by makeJsonError().

std::shared_ptr<oatpp::web::protocol::http::outgoing::Response> DtAuthHelpers::makeJsonError ( const oatpp::web::protocol::http::Status &  status,
const std::string &  message 
)
inline

Builds a minimal JSON error response.

References makeJsonResponse(), and ImGui::Value().

Referenced by requirePermission(), and requireValidSession().

bool DtAuthHelpers::parseJsonBody ( const std::shared_ptr< oatpp::web::protocol::http::incoming::Request > &  request,
Json::Value &  out,
std::string &  errors 
)
inline

Parses the JSON body from a request. Returns false and sets errors if the body is missing, empty, or not valid JSON.

std::string DtAuthHelpers::extractSessionKey ( const std::shared_ptr< oatpp::web::protocol::http::incoming::Request > &  request)
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().

std::shared_ptr<oatpp::web::protocol::http::outgoing::Response> DtAuthHelpers::requirePermission ( const std::shared_ptr< oatpp::web::protocol::http::incoming::Request > &  request,
const std::string &  permission 
)
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().

std::shared_ptr<oatpp::web::protocol::http::outgoing::Response> DtAuthHelpers::requireValidSession ( const std::shared_ptr< oatpp::web::protocol::http::incoming::Request > &  request)
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().


Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)