qBittorrent
|
#include <webapplication.h>
Classes | |
struct | TranslatedFile |
Public Member Functions | |
WebApplication (QObject *parent=nullptr) | |
~WebApplication () override | |
Http::Response | processRequest (const Http::Request &request, const Http::Environment &env) override |
QString | clientId () const override |
WebSession * | session () override |
void | sessionStart () override |
void | sessionEnd () override |
const Http::Request & | request () const |
const Http::Environment & | env () const |
Public Member Functions inherited from Http::IRequestHandler | |
virtual | ~IRequestHandler () |
Public Member Functions inherited from ISessionManager | |
virtual | ~ISessionManager ()=default |
Private Member Functions | |
void | doProcessRequest () |
void | configure () |
void | registerAPIController (const QString &scope, APIController *controller) |
void | declarePublicAPI (const QString &apiPath) |
void | sendFile (const QString &path) |
void | sendWebUIFile () |
void | translateDocument (QString &data) const |
QString | generateSid () const |
void | sessionInitialize () |
bool | isAuthNeeded () |
bool | isPublicAPI (const QString &scope, const QString &action) const |
bool | isCrossSiteRequest (const Http::Request &request) const |
bool | validateHostHeader (const QStringList &domains) const |
QHostAddress | resolveClientAddress () const |
Private Member Functions inherited from Http::ResponseBuilder | |
void | status (uint code=200, const QString &text=QLatin1String("OK")) |
void | setHeader (const Header &header) |
void | print (const QString &text, const QString &type=CONTENT_TYPE_HTML) |
void | print (const QByteArray &data, const QString &type=CONTENT_TYPE_HTML) |
void | clear () |
Response | response () const |
Definition at line 70 of file webapplication.h.
|
explicit |
Definition at line 119 of file webapplication.cpp.
References Preferences::changed(), configure(), declarePublicAPI(), Preferences::instance(), and registerAPIController().
|
override |
|
overridevirtual |
Implements ISessionManager.
Definition at line 534 of file webapplication.cpp.
References m_clientAddress.
|
private |
Definition at line 318 of file webapplication.cpp.
References Utils::Fs::expandPathAbs(), Http::HEADER_CONTENT_SECURITY_POLICY, Http::HEADER_REFERRER_POLICY, Http::HEADER_X_CONTENT_TYPE_OPTIONS, Http::HEADER_X_FRAME_OPTIONS, Http::HEADER_X_XSS_PROTECTION, Preferences::instance(), LogMsg(), m_authSubnetWhitelist, m_currentLocale, m_domainList, m_isAltUIUsed, m_isAuthSubnetWhitelistEnabled, m_isCSRFProtectionEnabled, m_isHostHeaderValidationEnabled, m_isHttpsEnabled, m_isLocalAuthEnabled, m_isSecureCookieEnabled, m_prebuiltHeaders, m_rootFolder, m_sessionTimeout, m_translatedFiles, m_translationFileLoaded, m_translator, Log::WARNING, and WWW_FOLDER.
Referenced by WebApplication().
|
private |
Definition at line 435 of file webapplication.cpp.
References m_publicAPIs.
Referenced by WebApplication().
|
private |
Definition at line 260 of file webapplication.cpp.
References AccessDenied, tstool::action, BadData, BadParams, Conflict, Http::CONTENT_TYPE_JSON, Http::CONTENT_TYPE_TXT, files(), isPublicAPI(), m_apiControllers, m_apiPathPattern, m_params, Exception::message(), NotFound, Http::ResponseBuilder::print(), request(), APIController::run(), sendWebUIFile(), session(), and APIError::type().
Referenced by processRequest().
const Http::Environment & WebApplication::env | ( | ) | const |
Definition at line 255 of file webapplication.cpp.
References m_env.
Referenced by processRequest().
|
private |
Definition at line 573 of file webapplication.cpp.
References m_sessions, and Utils::Random::rand().
Referenced by sessionStart().
|
private |
Definition at line 589 of file webapplication.cpp.
References Utils::Net::isIPInRange(), Utils::Net::isLoopbackAddress(), m_authSubnetWhitelist, m_clientAddress, m_isAuthSubnetWhitelistEnabled, and m_isLocalAuthEnabled.
Referenced by sessionInitialize().
|
private |
Definition at line 646 of file webapplication.cpp.
References Http::Environment::clientAddress, Http::HEADER_HOST, Http::HEADER_ORIGIN, Http::HEADER_REFERER, Http::HEADER_X_FORWARDED_HOST, Http::Request::headers, LogMsg(), m_env, request(), anonymous_namespace{webapplication.cpp}::urlFromHostHeader(), and Log::WARNING.
Referenced by processRequest().
|
private |
Definition at line 598 of file webapplication.cpp.
References tstool::action, and m_publicAPIs.
Referenced by doProcessRequest().
|
overridevirtual |
Implements Http::IRequestHandler.
Definition at line 487 of file webapplication.cpp.
References asConst(), Http::ResponseBuilder::clear(), Http::CONTENT_TYPE_TXT, doProcessRequest(), env(), isCrossSiteRequest(), m_clientAddress, m_currentSession, m_domainList, m_env, m_isCSRFProtectionEnabled, m_isHostHeaderValidationEnabled, m_params, m_prebuiltHeaders, m_request, Exception::message(), Http::Request::method, Http::METHOD_GET, Http::Request::posts, Http::ResponseBuilder::print(), Http::Request::query, request(), resolveClientAddress(), Http::ResponseBuilder::response(), sessionInitialize(), Http::ResponseBuilder::setHeader(), Http::ResponseBuilder::status(), HTTPError::statusCode(), HTTPError::statusText(), and validateHostHeader().
|
private |
Definition at line 427 of file webapplication.cpp.
References m_apiControllers.
Referenced by WebApplication().
const Http::Request & WebApplication::request | ( | ) | const |
Definition at line 250 of file webapplication.cpp.
References m_request.
Referenced by doProcessRequest(), isCrossSiteRequest(), processRequest(), and sendWebUIFile().
|
private |
Definition at line 729 of file webapplication.cpp.
References Http::Environment::clientAddress, Http::HEADER_X_FORWARDED_FOR, Http::Request::headers, m_env, m_isReverseProxySupportEnabled, m_request, and m_trustedReverseProxyList.
Referenced by processRequest().
|
private |
Definition at line 440 of file webapplication.cpp.
References file(), Utils::Misc::friendlyUnit(), anonymous_namespace{webapplication.cpp}::getCachingInterval(), Http::HEADER_CACHE_CONTROL, m_translatedFiles, MAX_ALLOWED_FILESIZE, Http::ResponseBuilder::print(), Http::ResponseBuilder::setHeader(), and translateDocument().
Referenced by sendWebUIFile().
|
private |
Definition at line 144 of file webapplication.cpp.
References Http::CONTENT_TYPE_TXT, Utils::Fs::isRegularFile(), m_isAltUIUsed, m_rootFolder, Http::Request::path, PATH_PREFIX_ICONS, Http::ResponseBuilder::print(), PRIVATE_FOLDER, PUBLIC_FOLDER, request(), sendFile(), session(), and Http::ResponseBuilder::status().
Referenced by doProcessRequest().
|
overridevirtual |
Implements ISessionManager.
Definition at line 245 of file webapplication.cpp.
References m_currentSession.
Referenced by doProcessRequest(), sendWebUIFile(), and sessionStart().
|
overridevirtual |
Implements ISessionManager.
Definition at line 632 of file webapplication.cpp.
References C_SID, Http::HEADER_SET_COOKIE, WebSession::id(), m_currentSession, m_sessions, and Http::ResponseBuilder::setHeader().
|
private |
Definition at line 539 of file webapplication.cpp.
References C_SID, WebSession::hasExpired(), Http::Request::headers, isAuthNeeded(), m_currentSession, m_request, m_sessions, m_sessionTimeout, anonymous_namespace{webapplication.cpp}::parseCookie(), sessionStart(), and WebSession::updateTimestamp().
Referenced by processRequest().
|
overridevirtual |
Implements ISessionManager.
Definition at line 603 of file webapplication.cpp.
References C_SID, generateSid(), WebSession::hasExpired(), Http::HEADER_SET_COOKIE, WebSession::id(), m_currentSession, m_isCSRFProtectionEnabled, m_isHttpsEnabled, m_isSecureCookieEnabled, m_sessions, m_sessionTimeout, Algorithm::removeIf(), session(), and Http::ResponseBuilder::setHeader().
Referenced by sessionInitialize().
|
private |
Definition at line 206 of file webapplication.cpp.
References m_cacheID, m_currentLocale, m_translationFileLoaded, and m_translator.
Referenced by sendFile().
|
private |
Definition at line 693 of file webapplication.cpp.
References Http::Environment::clientAddress, Http::HEADER_HOST, Http::Request::headers, Http::Environment::localAddress, Http::Environment::localPort, LogMsg(), m_env, m_request, anonymous_namespace{webapplication.cpp}::urlFromHostHeader(), Log::WARNING, and Utils::String::wildcardToRegexPattern().
Referenced by processRequest().
|
private |
Definition at line 131 of file webapplication.h.
Referenced by doProcessRequest(), and registerAPIController().
|
private |
Definition at line 129 of file webapplication.h.
Referenced by doProcessRequest().
|
private |
Definition at line 149 of file webapplication.h.
Referenced by configure(), and isAuthNeeded().
|
private |
Definition at line 127 of file webapplication.h.
Referenced by translateDocument().
|
private |
Definition at line 162 of file webapplication.h.
Referenced by clientId(), isAuthNeeded(), and processRequest().
|
private |
Definition at line 143 of file webapplication.h.
Referenced by configure(), and translateDocument().
|
private |
Definition at line 123 of file webapplication.h.
Referenced by processRequest(), session(), sessionEnd(), sessionInitialize(), and sessionStart().
|
private |
Definition at line 153 of file webapplication.h.
Referenced by configure(), and processRequest().
|
private |
Definition at line 125 of file webapplication.h.
Referenced by env(), isCrossSiteRequest(), processRequest(), resolveClientAddress(), and validateHostHeader().
|
private |
Definition at line 133 of file webapplication.h.
Referenced by configure(), and sendWebUIFile().
|
private |
Definition at line 148 of file webapplication.h.
Referenced by configure(), and isAuthNeeded().
|
private |
Definition at line 154 of file webapplication.h.
Referenced by configure(), processRequest(), and sessionStart().
|
private |
Definition at line 156 of file webapplication.h.
Referenced by configure(), and processRequest().
|
private |
Definition at line 157 of file webapplication.h.
Referenced by configure(), and sessionStart().
|
private |
Definition at line 147 of file webapplication.h.
Referenced by configure(), and isAuthNeeded().
|
private |
Definition at line 160 of file webapplication.h.
Referenced by resolveClientAddress().
|
private |
Definition at line 155 of file webapplication.h.
Referenced by configure(), and sessionStart().
|
private |
Definition at line 126 of file webapplication.h.
Referenced by doProcessRequest(), and processRequest().
|
private |
Definition at line 164 of file webapplication.h.
Referenced by configure(), and processRequest().
|
private |
Definition at line 132 of file webapplication.h.
Referenced by declarePublicAPI(), and isPublicAPI().
|
private |
Definition at line 124 of file webapplication.h.
Referenced by processRequest(), request(), resolveClientAddress(), sessionInitialize(), and validateHostHeader().
|
private |
Definition at line 134 of file webapplication.h.
Referenced by configure(), and sendWebUIFile().
|
private |
Definition at line 120 of file webapplication.h.
Referenced by generateSid(), sessionEnd(), sessionInitialize(), sessionStart(), and ~WebApplication().
|
private |
Definition at line 150 of file webapplication.h.
Referenced by configure(), sessionInitialize(), and sessionStart().
|
private |
Definition at line 142 of file webapplication.h.
Referenced by configure(), and sendFile().
|
private |
Definition at line 145 of file webapplication.h.
Referenced by configure(), and translateDocument().
|
private |
Definition at line 144 of file webapplication.h.
Referenced by configure(), and translateDocument().
|
private |
Definition at line 161 of file webapplication.h.
Referenced by resolveClientAddress().