Implement MG_ENTERPRISE CMake flag
Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2658
This commit is contained in:
@@ -134,6 +134,7 @@ set(libs_dir ${CMAKE_SOURCE_DIR}/libs)
|
||||
add_subdirectory(libs EXCLUDE_FROM_ALL)
|
||||
|
||||
# Optional subproject configuration -------------------------------------------
|
||||
option(MG_ENTERPRISE "Build Memgraph Enterprise Edition" ON)
|
||||
option(TEST_COVERAGE "Generate coverage reports from running memgraph" OFF)
|
||||
option(TOOLS "Build tools binaries" ON)
|
||||
option(QUERY_MODULES "Build query modules containing custom procedures" ON)
|
||||
@@ -150,6 +151,10 @@ if (TEST_COVERAGE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
|
||||
endif()
|
||||
|
||||
if (MG_ENTERPRISE)
|
||||
add_definitions(-DMG_ENTERPRISE)
|
||||
endif()
|
||||
|
||||
if (ASAN)
|
||||
# Enable Addres sanitizer and get nicer stack traces in error messages.
|
||||
# NOTE: AddressSanitizer uses llvm-symbolizer binary from the Clang
|
||||
|
||||
@@ -27,5 +27,7 @@ install(PROGRAMS $<TARGET_FILE:example>
|
||||
# Also install the source of the example, so user can read it.
|
||||
install(FILES example.c DESTINATION lib/memgraph/query_modules)
|
||||
|
||||
add_subdirectory(louvain)
|
||||
add_subdirectory(connectivity)
|
||||
if (MG_ENTERPRISE)
|
||||
add_subdirectory(louvain)
|
||||
add_subdirectory(connectivity)
|
||||
endif()
|
||||
|
||||
@@ -17,12 +17,21 @@ set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${memgraph_VERSION}-${COMMIT_H
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "tech@memgraph.com (Memgraph Ltd.)")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION non-free/database)
|
||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE https://memgraph.com)
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/conffiles;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/copyright;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/prerm;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;")
|
||||
if (MG_ENTERPRISE)
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/enterprise/conffiles;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/enterprise/copyright;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/prerm;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;")
|
||||
else()
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/community/conffiles;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/community/copyright;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/prerm;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm;"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;")
|
||||
endif()
|
||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||
# Description formatting is important, summary must be followed with a newline and 1 space.
|
||||
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
|
||||
@@ -38,7 +47,11 @@ set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
|
||||
/var /var/lib /var/log /etc/logrotate.d
|
||||
/lib /lib/systemd /lib/systemd/system /lib/systemd/system/memgraph.service)
|
||||
set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils")
|
||||
set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_SOURCE_DIR}/rpm/memgraph.spec.in")
|
||||
if (ME_ENTERPRISE)
|
||||
set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_SOURCE_DIR}/rpm/enterprise/memgraph.spec.in")
|
||||
else()
|
||||
set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_SOURCE_DIR}/rpm/community/memgraph.spec.in")
|
||||
endif()
|
||||
# Description formatting is important, no line must be greater than 80 characters.
|
||||
set(CPACK_RPM_PACKAGE_DESCRIPTION "Contains Memgraph, the graph database.
|
||||
It aims to deliver developers the speed, simplicity and scale required to build
|
||||
|
||||
68
release/LICENSE_ENTERPRISE_TRIAL.md
Normal file
68
release/LICENSE_ENTERPRISE_TRIAL.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# User License Agreement
|
||||
|
||||
1. Description
|
||||
|
||||
THIS LICENSE AGREEMENT GOVERNS LICENSEE’S USE OF THE MEMGRAPH ENTERPRISE
|
||||
RELEASE AND DOCUMENTATION UNDER A TRIAL LICENSE.
|
||||
|
||||
2. Trial License Grant
|
||||
|
||||
The Software and Documentation are provided to Licensee at no charge and are
|
||||
licensed, not sold to Licensee. No ownership of any part of the Software and
|
||||
Documentation is hereby transferred to Licensee. Subject to (i) the terms and
|
||||
conditions of this License Agreement, (ii) any additional license restrictions
|
||||
and parameters contained on Licensor’s quotation, website, or order form
|
||||
(“Order Form”), Licensor hereby grants Licensee a personal, non-assignable,
|
||||
non-transferable and non-exclusive license to install, access and use the
|
||||
Software (in object code form only) and Documentation for Licensee’s internal
|
||||
business purposes only. All rights relating to the Software and Documentation
|
||||
that are not expressly licensed in this License Agreement, whether now existing
|
||||
or which may hereafter come into existence are reserved for Licensor. Licensee
|
||||
shall not remove, obscure, or alter any proprietary rights notices (including
|
||||
without limitation copyright and trademark notices), which may be affixed to or
|
||||
contained within the Software or Documentation.
|
||||
|
||||
The Memgraph Enterprise Release Trial License is granted without charge for the
|
||||
trial or evaluation period specified when the Memgraph Enterprise Release was
|
||||
delivered, or if no term was specified, for thirty (30) calendar days. You may
|
||||
not use the Memgraph Enterprise Release under the Trial License more than once
|
||||
in any twelve (12) month period. Memgraph may revoke the Trial License at any
|
||||
time and for any reason.
|
||||
|
||||
3. Restrictions
|
||||
|
||||
Licensee will not, directly or indirectly, (a) copy the Software or
|
||||
Documentation in any manner or for any purpose; (b) install, access or use any
|
||||
component of the Software or Documentation for any purpose not expressly
|
||||
granted in Section 2 above; (c) resell, distribute, publicly display or
|
||||
publicly perform the Software or Documentation or any component thereof, by
|
||||
transfer, lease, loan or any other means, or make it available for use by
|
||||
others in any time-sharing, service bureau or similar arrangement; (d)
|
||||
disassemble, decrypt, extract, reverse engineer or reverse compile the
|
||||
Software, or otherwise attempt to discover the source code, confidential
|
||||
algorithms or techniques incorporated in the Software; (e) export the Software
|
||||
or Documentation in violation of any applicable laws or regulations; (f)
|
||||
modify, translate, adapt, or create derivative works from the Software or
|
||||
Documentation; (g) circumvent, disable or otherwise interfere with
|
||||
security-related features of the Software or Documentation; (h)
|
||||
reverse-engineer, disassemble, attempt to derive the source code; (i) use the
|
||||
Software or Documentation for any illegal purpose, in any manner that is
|
||||
inconsistent with the terms of this License Agreement, or to engage in illegal
|
||||
activity; (j) remove or alter any trademark, logo, copyright or other
|
||||
proprietary notices, legends, symbols or labels on, or embedded in, the
|
||||
Software or Documentation; or (k) provide access to the Software or
|
||||
Documentation to third parties.
|
||||
|
||||
4. Warranty Disclaimer
|
||||
|
||||
THE MEMGRAPH ENTERPRISE RELEASE AND DOCUMENTATION UNDER THE TRIAL LICENSE ARE
|
||||
PROVIDED “AS IS” FOR DEVELOPMENT, TESTING, AND EVALUATION PURPOSES ONLY. IT IS
|
||||
NOT LICENSED FOR PRODUCTION USE AND LICENSOR MAKES NO AND DISCLAIMS ALL
|
||||
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON
|
||||
INFRINGEMENT OF THIRD PARTIES’ INTELLECTUAL PROPERTY RIGHTS OR OTHER
|
||||
PROPRIETARY RIGHTS. NEITHER THIS LICENSE AGREEMENT NOR ANY DOCUMENTATION
|
||||
FURNISHED UNDER IT IS INTENDED TO EXPRESS OR IMPLY ANY WARRANTY THAT THE
|
||||
OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED, TIMELY, OR ERROR-FREE.
|
||||
|
||||
BY DOWNLOADING AND/OR ACCESSING THIS SOFTWARE, YOU AGREE TO SUCH TERMS.
|
||||
2
release/debian/community/conffiles
Normal file
2
release/debian/community/conffiles
Normal file
@@ -0,0 +1,2 @@
|
||||
/etc/memgraph/memgraph.conf
|
||||
/etc/logrotate.d/memgraph
|
||||
1
release/debian/community/copyright
Symbolic link
1
release/debian/community/copyright
Symbolic link
@@ -0,0 +1 @@
|
||||
../../LICENSE_COMMUNITY.md
|
||||
@@ -1 +0,0 @@
|
||||
../LICENSE.md
|
||||
1
release/debian/enterprise/copyright
Symbolic link
1
release/debian/enterprise/copyright
Symbolic link
@@ -0,0 +1 @@
|
||||
../../LICENSE_ENTERPRISE_TRIAL.md
|
||||
127
release/rpm/community/memgraph.spec.in
Normal file
127
release/rpm/community/memgraph.spec.in
Normal file
@@ -0,0 +1,127 @@
|
||||
# -*- rpm-spec -*-
|
||||
BuildRoot: %_topdir/@CPACK_PACKAGE_FILE_NAME@@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH@
|
||||
Summary: @CPACK_RPM_PACKAGE_SUMMARY@
|
||||
Name: @CPACK_RPM_PACKAGE_NAME@
|
||||
Version: @CPACK_RPM_PACKAGE_VERSION@
|
||||
Release: @CPACK_RPM_PACKAGE_RELEASE@
|
||||
License: @CPACK_RPM_PACKAGE_LICENSE@
|
||||
# Group field is deprecated
|
||||
# Group: @CPACK_RPM_PACKAGE_GROUP@
|
||||
Vendor: @CPACK_RPM_PACKAGE_VENDOR@
|
||||
BuildRequires: systemd
|
||||
|
||||
@TMP_RPM_URL@
|
||||
@TMP_RPM_REQUIRES@
|
||||
@TMP_RPM_REQUIRES_PRE@
|
||||
@TMP_RPM_REQUIRES_POST@
|
||||
@TMP_RPM_REQUIRES_PREUN@
|
||||
@TMP_RPM_REQUIRES_POSTUN@
|
||||
@TMP_RPM_PROVIDES@
|
||||
@TMP_RPM_OBSOLETES@
|
||||
@TMP_RPM_CONFLICTS@
|
||||
@TMP_RPM_AUTOPROV@
|
||||
@TMP_RPM_AUTOREQ@
|
||||
@TMP_RPM_AUTOREQPROV@
|
||||
@TMP_RPM_BUILDARCH@
|
||||
@TMP_RPM_PREFIXES@
|
||||
|
||||
@TMP_RPM_DEBUGINFO@
|
||||
|
||||
%define _rpmdir %_topdir/RPMS
|
||||
%define _srcrpmdir %_topdir/SRPMS
|
||||
@FILE_NAME_DEFINE@
|
||||
%define _unpackaged_files_terminate_build 0
|
||||
@TMP_RPM_SPEC_INSTALL_POST@
|
||||
@CPACK_RPM_SPEC_MORE_DEFINE@
|
||||
@CPACK_RPM_COMPRESSION_TYPE_TMP@
|
||||
|
||||
%description
|
||||
@CPACK_RPM_PACKAGE_DESCRIPTION@
|
||||
|
||||
# This is a shortcutted spec file generated by CMake RPM generator
|
||||
# we skip _install step because CPack does that for us.
|
||||
# We do only save CPack installed tree in _prepr
|
||||
# and then restore it in build.
|
||||
%prep
|
||||
# Put the systemd unit where it is expected on this system
|
||||
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
|
||||
mv $RPM_BUILD_ROOT/lib/systemd/system/memgraph.service $RPM_BUILD_ROOT/%{_unitdir}
|
||||
rm -rf $RPM_BUILD_ROOT/lib
|
||||
# Fix the incorrect directory permissions set by cpack (this is fixed in CMake 3.11)
|
||||
find $RPM_BUILD_ROOT -type d | xargs chmod 755
|
||||
# After setting up custom prep, continue with CMake's default
|
||||
mv $RPM_BUILD_ROOT %_topdir/tmpBBroot
|
||||
|
||||
%install
|
||||
if [ -e $RPM_BUILD_ROOT ];
|
||||
then
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
fi
|
||||
mv %_topdir/tmpBBroot $RPM_BUILD_ROOT
|
||||
|
||||
@TMP_RPM_DEBUGINFO_INSTALL@
|
||||
|
||||
%clean
|
||||
|
||||
%post
|
||||
# memgraph user and group must be set in preinst
|
||||
chown memgraph:memgraph /var/lib/memgraph || exit 1
|
||||
chmod 750 /var/lib/memgraph || exit 1
|
||||
chown memgraph:adm /var/log/memgraph || exit 1
|
||||
chmod 750 /var/log/memgraph || exit 1
|
||||
|
||||
# Create telemetry directory in examples
|
||||
for i in /usr/share/memgraph/examples/*; do
|
||||
# The telemetry directory may already exist from some prior installation
|
||||
if [ ! -d $i/telemetry ]; then
|
||||
mkdir $i/telemetry || exit 1
|
||||
fi
|
||||
chown -R memgraph:memgraph $i/telemetry || exit 1
|
||||
# Make snapshots directory immutable (optional)
|
||||
chattr +i -R $i/snapshots || true
|
||||
done
|
||||
|
||||
# Generate SSL certificates
|
||||
if [ ! -d /etc/memgraph/ssl ]; then
|
||||
mkdir /etc/memgraph/ssl || exit 1
|
||||
openssl req -x509 -newkey rsa:4096 -days 3650 -nodes \
|
||||
-keyout /etc/memgraph/ssl/key.pem -out /etc/memgraph/ssl/cert.pem \
|
||||
-subj "/C=GB/ST=London/L=London/O=Memgraph Ltd./CN=Memgraph DB" || exit 1
|
||||
chown memgraph:memgraph /etc/memgraph/ssl/* || exit 1
|
||||
chmod 400 /etc/memgraph/ssl/* || exit 1
|
||||
fi
|
||||
@RPM_SYMLINK_POSTINSTALL@
|
||||
@CPACK_RPM_SPEC_POSTINSTALL@
|
||||
|
||||
%postun
|
||||
@CPACK_RPM_SPEC_POSTUNINSTALL@
|
||||
|
||||
%pre
|
||||
# Add the 'memgraph' user and group
|
||||
getent group memgraph >/dev/null || groupadd -r memgraph || exit 1
|
||||
getent passwd memgraph >/dev/null || \
|
||||
useradd -r -g memgraph -d /var/lib/memgraph -s /bin/bash memgraph || exit 1
|
||||
echo "Don't forget to switch to the 'memgraph' user to use Memgraph" || exit 1
|
||||
@CPACK_RPM_SPEC_PREINSTALL@
|
||||
|
||||
%preun
|
||||
# Remove optional immutability from examples directory to allow removal
|
||||
chattr -i -R /usr/share/memgraph/examples || true
|
||||
@CPACK_RPM_SPEC_PREUNINSTALL@
|
||||
|
||||
%files
|
||||
%defattr(@TMP_DEFAULT_FILE_PERMISSIONS@,@TMP_DEFAULT_USER@,@TMP_DEFAULT_GROUP@,@TMP_DEFAULT_DIR_PERMISSIONS@)
|
||||
@CPACK_RPM_INSTALL_FILES@
|
||||
# Since we moved the memgraph.service file, declare it explicitly here.
|
||||
# NOTE: memgraph.service must not be marked as configuration file.
|
||||
%{_unitdir}/memgraph.service
|
||||
|
||||
# Override CPACK_RPM_ABSOLUTE_INSTALL_FILES with our %config(noreplace), cpack
|
||||
# uses plain %config.
|
||||
%config(noreplace) "/etc/memgraph/memgraph.conf"
|
||||
%config(noreplace) "/etc/logrotate.d/memgraph"
|
||||
|
||||
@CPACK_RPM_USER_INSTALL_FILES@
|
||||
|
||||
%changelog
|
||||
@CPACK_RPM_SPEC_CHANGELOG@
|
||||
@@ -8,12 +8,14 @@ add_subdirectory(io)
|
||||
add_subdirectory(kvstore)
|
||||
add_subdirectory(telemetry)
|
||||
add_subdirectory(communication)
|
||||
add_subdirectory(auth)
|
||||
add_subdirectory(slk)
|
||||
add_subdirectory(rpc)
|
||||
add_subdirectory(storage/v2)
|
||||
add_subdirectory(query)
|
||||
add_subdirectory(audit)
|
||||
if (MG_ENTERPRISE)
|
||||
add_subdirectory(audit)
|
||||
add_subdirectory(auth)
|
||||
add_subdirectory(slk)
|
||||
add_subdirectory(rpc)
|
||||
endif()
|
||||
|
||||
## ----------------------------------------------------------------------------
|
||||
## Common LCP files
|
||||
@@ -44,7 +46,6 @@ add_subdirectory(audit)
|
||||
# durability/single_node_ha/paths.cpp
|
||||
# durability/single_node_ha/snapshooter.cpp
|
||||
# durability/single_node_ha/recovery.cpp
|
||||
# glue/auth.cpp
|
||||
# glue/communication.cpp
|
||||
# raft/coordination.cpp
|
||||
# raft/raft_server.cpp
|
||||
@@ -79,6 +80,11 @@ add_subdirectory(audit)
|
||||
# transactions/single_node_ha/engine.cpp
|
||||
# memgraph_init.cpp
|
||||
#)
|
||||
#if (MG_ENTERPRISE)
|
||||
# set(mg_single_node_ha_sources
|
||||
# ${mg_single_node_ha_sources}
|
||||
# glue/auth.cpp)
|
||||
#endif()
|
||||
#
|
||||
#define_add_lcp(add_lcp_single_node_ha mg_single_node_ha_sources generated_lcp_single_node_ha_files)
|
||||
#
|
||||
@@ -128,16 +134,22 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
# Memgraph Single Node v2 Executable
|
||||
# ----------------------------------------------------------------------------
|
||||
set(mg_single_node_v2_sources
|
||||
glue/auth.cpp
|
||||
glue/communication.cpp
|
||||
memgraph_init.cpp
|
||||
memgraph.cpp
|
||||
)
|
||||
if (MG_ENTERPRISE)
|
||||
set(mg_single_node_v2_sources
|
||||
${mg_single_node_v2_sources}
|
||||
glue/auth.cpp)
|
||||
endif()
|
||||
|
||||
set(MG_SINGLE_NODE_V2_LIBS stdc++fs Threads::Threads
|
||||
telemetry_lib mg-query mg-communication)
|
||||
# These are enterprise subsystems
|
||||
set(MG_SINGLE_NODE_V2_LIBS ${MG_SINGLE_NODE_V2_LIBS} mg-auth mg-audit)
|
||||
if (MG_ENTERPRISE)
|
||||
# These are enterprise subsystems
|
||||
set(MG_SINGLE_NODE_V2_LIBS ${MG_SINGLE_NODE_V2_LIBS} mg-auth mg-audit)
|
||||
endif()
|
||||
|
||||
# memgraph main executable
|
||||
add_executable(memgraph ${mg_single_node_v2_sources})
|
||||
@@ -200,14 +212,21 @@ install(FILES ${CMAKE_BINARY_DIR}/config/memgraph.conf
|
||||
# Install logrotate configuration (must use absolute path).
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/logrotate.conf
|
||||
DESTINATION /etc/logrotate.d RENAME memgraph)
|
||||
if (MG_ENTERPRISE)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/logrotate_audit.conf
|
||||
DESTINATION /etc/logrotate.d RENAME memgraph_audit)
|
||||
endif()
|
||||
# Create empty directories for default location of lib and log.
|
||||
install(CODE "file(MAKE_DIRECTORY \$ENV{DESTDIR}/var/log/memgraph
|
||||
\$ENV{DESTDIR}/var/lib/memgraph)")
|
||||
# Install the license file.
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/LICENSE.md
|
||||
DESTINATION share/doc/memgraph RENAME copyright)
|
||||
if (MG_ENTERPRISE)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/LICENSE_ENTERPRISE_TRIAL.md
|
||||
DESTINATION share/doc/memgraph RENAME copyright)
|
||||
else()
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/LICENSE_COMMUNITY.md
|
||||
DESTINATION share/doc/memgraph RENAME copyright)
|
||||
endif()
|
||||
# Install systemd service (must use absolute path).
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/release/memgraph.service
|
||||
DESTINATION /lib/systemd/system)
|
||||
|
||||
@@ -10,16 +10,19 @@
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "communication/server.hpp"
|
||||
#include "storage/v2/storage.hpp"
|
||||
#include "glue/auth.hpp"
|
||||
#include "memgraph_init.hpp"
|
||||
#include "query/exceptions.hpp"
|
||||
#include "query/procedure/module.hpp"
|
||||
#include "storage/v2/storage.hpp"
|
||||
#include "telemetry/telemetry.hpp"
|
||||
#include "utils/file.hpp"
|
||||
#include "utils/flag_validation.hpp"
|
||||
#include "utils/string.hpp"
|
||||
|
||||
#ifdef MG_ENTERPRISE
|
||||
#include "glue/auth.hpp"
|
||||
#endif
|
||||
|
||||
// General purpose flags.
|
||||
DEFINE_string(bolt_address, "0.0.0.0",
|
||||
"IP address on which the Bolt server should listen.");
|
||||
@@ -83,6 +86,7 @@ DEFINE_bool(telemetry_enabled, false,
|
||||
"to allow for easier improvement of the product.");
|
||||
|
||||
// Audit logging flags.
|
||||
#ifdef MG_ENTERPRISE
|
||||
DEFINE_bool(audit_enabled, false, "Set to true to enable audit logging.");
|
||||
DEFINE_VALIDATED_int32(audit_buffer_size, audit::kBufferSizeDefault,
|
||||
"Maximum number of items in the audit log buffer.",
|
||||
@@ -91,6 +95,7 @@ DEFINE_VALIDATED_int32(
|
||||
audit_buffer_flush_interval_ms, audit::kBufferFlushIntervalMillisDefault,
|
||||
"Interval (in milliseconds) used for flushing the audit log buffer.",
|
||||
FLAG_IN_RANGE(10, INT32_MAX));
|
||||
#endif
|
||||
|
||||
// Query flags.
|
||||
DEFINE_uint64(query_execution_timeout_sec, 180,
|
||||
@@ -110,6 +115,7 @@ DEFINE_VALIDATED_string(
|
||||
using ServerT = communication::Server<BoltSession, SessionData>;
|
||||
using communication::ServerContext;
|
||||
|
||||
#ifdef MG_ENTERPRISE
|
||||
class AuthQueryHandler final : public query::AuthQueryHandler {
|
||||
auth::Auth *auth_;
|
||||
|
||||
@@ -415,11 +421,87 @@ class AuthQueryHandler final : public query::AuthQueryHandler {
|
||||
}
|
||||
}
|
||||
};
|
||||
#else
|
||||
class NoAuthInCommunity : public query::QueryRuntimeException {
|
||||
public:
|
||||
NoAuthInCommunity()
|
||||
: query::QueryRuntimeException::QueryRuntimeException(
|
||||
"Auth is not supported in Memgraph Community!") {}
|
||||
};
|
||||
|
||||
class AuthQueryHandler final : public query::AuthQueryHandler {
|
||||
public:
|
||||
bool CreateUser(const std::string &,
|
||||
const std::optional<std::string> &) override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
bool DropUser(const std::string &) override { throw NoAuthInCommunity(); }
|
||||
|
||||
void SetPassword(const std::string &,
|
||||
const std::optional<std::string> &) override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
bool CreateRole(const std::string &) override { throw NoAuthInCommunity(); }
|
||||
|
||||
bool DropRole(const std::string &) override { throw NoAuthInCommunity(); }
|
||||
|
||||
std::vector<query::TypedValue> GetUsernames() override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
std::vector<query::TypedValue> GetRolenames() override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
std::optional<std::string> GetRolenameForUser(const std::string &) override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
std::vector<query::TypedValue> GetUsernamesForRole(
|
||||
const std::string &) override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
void SetRole(const std::string &, const std::string &) override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
void ClearRole(const std::string &) override { throw NoAuthInCommunity(); }
|
||||
|
||||
std::vector<std::vector<query::TypedValue>> GetPrivileges(
|
||||
const std::string &) override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
void GrantPrivilege(
|
||||
const std::string &,
|
||||
const std::vector<query::AuthQuery::Privilege> &) override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
void DenyPrivilege(
|
||||
const std::string &,
|
||||
const std::vector<query::AuthQuery::Privilege> &) override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
|
||||
void RevokePrivilege(
|
||||
const std::string &,
|
||||
const std::vector<query::AuthQuery::Privilege> &) override {
|
||||
throw NoAuthInCommunity();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
void SingleNodeMain() {
|
||||
std::cout << "You are running Memgraph v" << gflags::VersionString()
|
||||
<< std::endl;
|
||||
|
||||
auto data_directory = std::filesystem::path(FLAGS_data_directory);
|
||||
|
||||
#ifdef MG_ENTERPRISE
|
||||
// All enterprise features should be constructed before the main database
|
||||
// storage. This will cause them to be destructed *after* the main database
|
||||
// storage. That way any errors that happen during enterprise features
|
||||
@@ -431,8 +513,6 @@ void SingleNodeMain() {
|
||||
|
||||
// Begin enterprise features initialization
|
||||
|
||||
auto data_directory = std::filesystem::path(FLAGS_data_directory);
|
||||
|
||||
// Auth
|
||||
auth::Auth auth{data_directory / "auth"};
|
||||
|
||||
@@ -450,6 +530,7 @@ void SingleNodeMain() {
|
||||
<< "Unable to register SIGUSR2 handler!";
|
||||
|
||||
// End enterprise features initialization
|
||||
#endif
|
||||
|
||||
// Main storage and execution engines initialization
|
||||
|
||||
@@ -486,7 +567,11 @@ void SingleNodeMain() {
|
||||
query::InterpreterContext interpreter_context{&db};
|
||||
query::SetExecutionTimeout(&interpreter_context,
|
||||
FLAGS_query_execution_timeout_sec);
|
||||
#ifdef MG_ENTERPRISE
|
||||
SessionData session_data{&db, &interpreter_context, &auth, &audit_log};
|
||||
#else
|
||||
SessionData session_data{&db, &interpreter_context};
|
||||
#endif
|
||||
|
||||
// Register modules
|
||||
if (!FLAGS_query_modules_directory.empty()) {
|
||||
@@ -497,7 +582,11 @@ void SingleNodeMain() {
|
||||
}
|
||||
}
|
||||
// Register modules END
|
||||
#ifdef MG_ENTERPRISE
|
||||
AuthQueryHandler auth_handler(&auth);
|
||||
#else
|
||||
AuthQueryHandler auth_handler;
|
||||
#endif
|
||||
interpreter_context.auth = &auth_handler;
|
||||
|
||||
ServerContext context;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "glue/auth.hpp"
|
||||
#include "glue/communication.hpp"
|
||||
#include "query/exceptions.hpp"
|
||||
#include "requests/requests.hpp"
|
||||
@@ -13,6 +12,10 @@
|
||||
#include "utils/terminate_handler.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#ifdef MG_ENTERPRISE
|
||||
#include "glue/auth.hpp"
|
||||
#endif
|
||||
|
||||
DEFINE_string(log_file, "", "Path to where the log should be stored.");
|
||||
DEFINE_HIDDEN_string(
|
||||
log_link_basename, "",
|
||||
@@ -34,9 +37,11 @@ BoltSession::BoltSession(SessionData *data,
|
||||
output_stream),
|
||||
db_(data->db),
|
||||
interpreter_(data->interpreter_context),
|
||||
#ifdef MG_ENTERPRISE
|
||||
#ifndef MG_SINGLE_NODE_HA
|
||||
auth_(data->auth),
|
||||
audit_log_(data->audit_log),
|
||||
#endif
|
||||
#endif
|
||||
endpoint_(endpoint) {
|
||||
}
|
||||
@@ -51,12 +56,15 @@ std::vector<std::string> BoltSession::Interpret(
|
||||
std::map<std::string, storage::PropertyValue> params_pv;
|
||||
for (const auto &kv : params)
|
||||
params_pv.emplace(kv.first, glue::ToPropertyValue(kv.second));
|
||||
#ifdef MG_ENTERPRISE
|
||||
#ifndef MG_SINGLE_NODE_HA
|
||||
audit_log_->Record(endpoint_.address(), user_ ? user_->username() : "", query,
|
||||
storage::PropertyValue(params_pv));
|
||||
#endif
|
||||
#endif
|
||||
try {
|
||||
auto result = interpreter_.Prepare(query, params_pv);
|
||||
#ifdef MG_ENTERPRISE
|
||||
#ifndef MG_SINGLE_NODE_HA
|
||||
if (user_) {
|
||||
const auto &permissions = user_->GetPermissions();
|
||||
@@ -70,6 +78,7 @@ std::vector<std::string> BoltSession::Interpret(
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return result.first;
|
||||
|
||||
@@ -113,6 +122,7 @@ void BoltSession::Abort() { interpreter_.Abort(); }
|
||||
|
||||
bool BoltSession::Authenticate(const std::string &username,
|
||||
const std::string &password) {
|
||||
#ifdef MG_ENTERPRISE
|
||||
#ifdef MG_SINGLE_NODE_HA
|
||||
return true;
|
||||
#else
|
||||
@@ -120,6 +130,9 @@ bool BoltSession::Authenticate(const std::string &username,
|
||||
user_ = auth_->Authenticate(username, password);
|
||||
return !!user_;
|
||||
#endif
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::optional<std::string> BoltSession::GetServerNameForInit() {
|
||||
|
||||
@@ -9,31 +9,46 @@
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include "audit/log.hpp"
|
||||
#include "auth/auth.hpp"
|
||||
#include "communication/bolt/v1/exceptions.hpp"
|
||||
#include "communication/bolt/v1/session.hpp"
|
||||
#include "communication/init.hpp"
|
||||
#include "communication/session.hpp"
|
||||
#include "query/interpreter.hpp"
|
||||
|
||||
#ifdef MG_ENTERPRISE
|
||||
#include "audit/log.hpp"
|
||||
#include "auth/auth.hpp"
|
||||
#endif
|
||||
|
||||
/// Encapsulates Dbms and Interpreter that are passed through the network server
|
||||
/// and worker to the session.
|
||||
#ifdef MG_ENTERPRISE
|
||||
struct SessionData {
|
||||
// Explicit constructor here to ensure that pointers to all objects are
|
||||
// supplied.
|
||||
SessionData(storage::Storage *_db,
|
||||
query::InterpreterContext *_interpreter_context,
|
||||
auth::Auth *_auth, audit::Log *_audit_log)
|
||||
: db(_db),
|
||||
interpreter_context(_interpreter_context),
|
||||
auth(_auth),
|
||||
audit_log(_audit_log) {}
|
||||
SessionData(storage::Storage *db,
|
||||
query::InterpreterContext *interpreter_context, auth::Auth *auth,
|
||||
audit::Log *audit_log)
|
||||
: db(db),
|
||||
interpreter_context(interpreter_context),
|
||||
auth(auth),
|
||||
audit_log(audit_log) {}
|
||||
storage::Storage *db;
|
||||
query::InterpreterContext *interpreter_context;
|
||||
auth::Auth *auth;
|
||||
audit::Log *audit_log;
|
||||
};
|
||||
#else
|
||||
struct SessionData {
|
||||
// Explicit constructor here to ensure that pointers to all objects are
|
||||
// supplied.
|
||||
SessionData(storage::Storage *db,
|
||||
query::InterpreterContext *interpreter_context)
|
||||
: db(db), interpreter_context(interpreter_context) {}
|
||||
storage::Storage *db;
|
||||
query::InterpreterContext *interpreter_context;
|
||||
};
|
||||
#endif
|
||||
|
||||
class BoltSession final
|
||||
: public communication::bolt::Session<communication::InputStream,
|
||||
@@ -78,10 +93,12 @@ class BoltSession final
|
||||
// NOTE: Needed only for ToBoltValue conversions
|
||||
const storage::Storage *db_;
|
||||
query::Interpreter interpreter_;
|
||||
#ifdef MG_ENTERPRISE
|
||||
#ifndef MG_SINGLE_NODE_HA
|
||||
auth::Auth *auth_;
|
||||
std::optional<auth::User> user_;
|
||||
audit::Log *audit_log_;
|
||||
#endif
|
||||
#endif
|
||||
io::network::Endpoint endpoint_;
|
||||
};
|
||||
|
||||
@@ -35,8 +35,10 @@ target_link_libraries(${test_prefix}profile mg-query)
|
||||
add_benchmark(query/stripped.cpp)
|
||||
target_link_libraries(${test_prefix}stripped mg-query)
|
||||
|
||||
if (MG_ENTERPRISE)
|
||||
add_benchmark(rpc.cpp)
|
||||
target_link_libraries(${test_prefix}rpc mg-rpc)
|
||||
endif()
|
||||
|
||||
add_benchmark(skip_list_random.cpp)
|
||||
target_link_libraries(${test_prefix}skip_list_random mg-utils)
|
||||
|
||||
@@ -235,12 +235,15 @@ target_link_libraries(${test_prefix}storage_v2_wal_file mg-storage-v2 fmt)
|
||||
|
||||
# Test mg-auth
|
||||
|
||||
if (MG_ENTERPRISE)
|
||||
add_unit_test(auth.cpp)
|
||||
target_link_libraries(${test_prefix}auth mg-auth)
|
||||
endif()
|
||||
|
||||
|
||||
# Test mg-slk
|
||||
|
||||
if (MG_ENTERPRISE)
|
||||
## TODO: REPLACE single-node-ha
|
||||
#add_unit_test(slk_advanced.cpp)
|
||||
#target_link_libraries(${test_prefix}slk_advanced mg-single-node-ha mg-kvstore-dummy)
|
||||
@@ -250,12 +253,15 @@ target_link_libraries(${test_prefix}slk_core mg-slk glog gflags fmt)
|
||||
|
||||
add_unit_test(slk_streams.cpp)
|
||||
target_link_libraries(${test_prefix}slk_streams mg-slk glog gflags fmt)
|
||||
endif()
|
||||
|
||||
|
||||
# Test mg-rpc
|
||||
|
||||
if (MG_ENTERPRISE)
|
||||
add_unit_test(rpc.cpp)
|
||||
target_link_libraries(${test_prefix}rpc mg-rpc)
|
||||
endif()
|
||||
|
||||
|
||||
# Test LCP
|
||||
|
||||
Reference in New Issue
Block a user