#include "BlogSession.h" #include #include #include #include #include #include #include class BlogOAuth : public std::vector { public: ~BlogOAuth() { for (unsigned i = 0; i < size(); ++i) delete (*this)[i]; } }; Wt::Auth::AuthService blogAuth; Wt::Auth::PasswordService blogPasswords(blogAuth); BlogOAuth blogOAuth; BlogSession::BlogSession(Wt::Dbo::SqlConnectionPool &connectionPool) : m_connectionPool(connectionPool), m_users(*this) { } void BlogSession::configureAuth() { blogAuth.setAuthTokensEnabled(true, "bloglogin"); std::unique_ptr verifier = std::make_unique(); verifier->addHashFunction(std::make_unique(7)); #ifdef WT_WITH_SSL verifier->addHashFunction(std::make_unique()); #endif #ifdef HAVE_CRYPT verifier->addHashFunction(std::make_unique()); #endif blogPasswords.setVerifier(std::move(verifier)); blogPasswords.setPasswordThrottle(std::make_unique()); blogPasswords.setStrengthValidator(std::make_unique()); if (Wt::Auth::GoogleService::configured()) blogOAuth.push_back(new Wt::Auth::GoogleService(blogAuth)); } std::unique_ptr BlogSession::createConnectionPool(const std::string &sqlite3) { auto connection = std::make_unique(sqlite3); connection->setProperty("show-queries", "true"); connection->setDateTimeStorage(Wt::Dbo::SqlDateTimeType::DateTime, Wt::Dbo::backend::DateTimeStorage::PseudoISO8601AsText); return std::make_unique(std::move(connection), 10); } Wt::Dbo::ptr BlogSession::user() const { if (m_login.loggedIn()) return m_users.find(m_login.user()); else return Wt::Dbo::ptr(); } Wt::Auth::PasswordService *BlogSession::passwordAuth() const { return &blogPasswords; } const std::vector &BlogSession::oAuth() const { return blogOAuth; }