#include "WebApplication.h" #include "BoostLog.h" #include "Hello.h" #include "Restful.h" #include "Session.h" #include #include #include #include #include #include #include static std::unique_ptr createApplication(const Wt::WEnvironment &env) { return std::make_unique(env, false); } static std::unique_ptr createWidgetSet(const Wt::WEnvironment &env) { return std::make_unique(env, true); } WebApplication::WebApplication() { try { std::vector args; args.push_back("--approot=./build"); args.push_back("--docroot=./build"); args.push_back("--http-listen=127.0.0.1:8855"); // --docroot=. --no-compression --http-listen 127.0.0.1:8855 initializeAuthenticationService(); m_server = std::make_unique("./build", args); m_server->addEntryPoint(Wt::EntryPointType::Application, createApplication, "/hello"); m_server->addEntryPoint(Wt::EntryPointType::WidgetSet, createWidgetSet, "/gui/hello.js"); m_server->addResource(std::make_shared(), "/auth"); m_server->addResource(std::make_shared(), "/plaintext"); m_server->addResource(std::make_shared("database.sqlite"), "/db"); m_server->start(); } catch (const std::exception &e) { LOG(error) << e.what(); } } WebApplication::~WebApplication() { } void WebApplication::initializeAuthenticationService() { m_authService = std::make_unique(); m_authService->setAuthTokensEnabled(true, "logincookie"); m_passwordService = std::make_unique(*m_authService); auto verifier = std::make_unique(); verifier->addHashFunction(std::make_unique(7)); m_passwordService->setVerifier(std::move(verifier)); m_passwordService->setPasswordThrottle(std::make_unique()); m_passwordService->setStrengthValidator(std::make_unique()); } const Wt::Auth::AuthService &WebApplication::authService() { return *m_authService; } const Wt::Auth::PasswordService &WebApplication::passwordService() { return *m_passwordService; }