// Copyright 2023 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source // License, and you may not use this file except in compliance with the Business Source License. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. #pragma once #include "audit/log.hpp" #include "auth/auth.hpp" #include "communication/v2/server.hpp" #include "communication/v2/session.hpp" #include "dbms/database.hpp" #include "query/interpreter.hpp" namespace memgraph::glue { class SessionHL final : public memgraph::communication::bolt::Session { public: SessionHL(memgraph::query::InterpreterContext *interpreter_context, memgraph::communication::v2::ServerEndpoint endpoint, memgraph::communication::v2::InputStream *input_stream, memgraph::communication::v2::OutputStream *output_stream, memgraph::utils::Synchronized *auth #ifdef MG_ENTERPRISE , memgraph::audit::Log *audit_log #endif ); ~SessionHL() override; SessionHL(const SessionHL &) = delete; SessionHL &operator=(const SessionHL &) = delete; SessionHL(SessionHL &&) = delete; SessionHL &operator=(SessionHL &&) = delete; void Configure(const std::map &run_time_info) override; using TEncoder = memgraph::communication::bolt::Encoder< memgraph::communication::bolt::ChunkedEncoderBuffer>; void BeginTransaction(const std::map &extra) override; void CommitTransaction() override; void RollbackTransaction() override; std::pair, std::optional> Interpret( const std::string &query, const std::map ¶ms, const std::map &extra) override; std::map Pull(TEncoder *encoder, std::optional n, std::optional qid) override; std::map Discard(std::optional n, std::optional qid) override; void Abort() override; // Called during Init bool Authenticate(const std::string &username, const std::string &password) override; std::optional GetServerNameForInit() override; std::string GetCurrentDB() const override; private: std::map DecodeSummary( const std::map &summary); /** * @brief Get the user's default database * * @return std::string */ std::string GetDefaultDB(); memgraph::query::InterpreterContext *interpreter_context_; memgraph::query::Interpreter interpreter_; std::optional user_; #ifdef MG_ENTERPRISE memgraph::audit::Log *audit_log_; bool in_explicit_db_{false}; //!< If true, the user has defined the database to use via metadata #endif memgraph::utils::Synchronized *auth_; memgraph::communication::v2::ServerEndpoint endpoint_; std::optional implicit_db_; }; } // namespace memgraph::glue