Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ljcui committed Jul 19, 2024
1 parent b91c7a8 commit 179a9f7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/cypher/procedure/procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "cypher/monitor/memory_monitor_allocator.h"
#include "fma-common/encrypt.h"
#include "import/import_v3.h"
#include "server/bolt_session.h"

namespace cypher {

Expand Down Expand Up @@ -1646,6 +1647,24 @@ void BuiltinProcedure::DbmsMetaRefreshCount(RTContext *ctx, const Record *record
ac_db.RefreshCount();
}

void BuiltinProcedure::DbmsSecurityIsDefaultUserPassword(RTContext *ctx, const cypher::Record *record,
const cypher::VEC_EXPR &args,
const cypher::VEC_STR &yield_items,
std::vector<Record> *records) {
CYPHER_ARG_CHECK(
args.size() == 0,
"need 0 parameters, e.g. dbms.security.isDefaultUserPassword()")
if (ctx->txn_) ctx->txn_->Abort();
bool is_default_user_password = false;
if (ctx->bolt_conn_) {
auto session = (bolt::BoltSession*)(ctx->bolt_conn_->GetContext());
is_default_user_password = session->using_default_user_password;
}
Record r;
r.AddConstant(lgraph::FieldData(is_default_user_password));
records->emplace_back(r.Snapshot());
}

void BuiltinProcedure::DbmsSecurityChangePassword(RTContext *ctx, const cypher::Record *record,
const cypher::VEC_EXPR &args,
const cypher::VEC_STR &yield_items,
Expand Down
9 changes: 9 additions & 0 deletions src/cypher/procedure/procedure.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ class BuiltinProcedure {
static void DbmsMetaRefreshCount(RTContext *ctx, const Record *record, const VEC_EXPR &args,
const VEC_STR &yield_items, std::vector<Record> *records);

static void DbmsSecurityIsDefaultUserPassword(RTContext *ctx, const Record *record,
const VEC_EXPR &args, const VEC_STR &yield_items,
std::vector<Record> *records);

static void DbmsSecurityChangePassword(RTContext *ctx, const Record *record,
const VEC_EXPR &args, const VEC_STR &yield_items,
std::vector<Record> *records);
Expand Down Expand Up @@ -728,6 +732,11 @@ static std::vector<Procedure> global_procedures = {
Procedure("dbms.meta.refreshCount", BuiltinProcedure::DbmsMetaRefreshCount,
Procedure::SIG_SPEC{}, Procedure::SIG_SPEC{{"", {0, lgraph_api::LGraphType::NUL}}},
false, true),
Procedure("dbms.security.isDefaultUserPassword", BuiltinProcedure::DbmsSecurityIsDefaultUserPassword,
Procedure::SIG_SPEC{},
Procedure::SIG_SPEC{
{"isDefaultUserPassword", {0, lgraph_api::LGraphType::BOOLEAN}}
}, true, false),
Procedure("dbms.security.changePassword", BuiltinProcedure::DbmsSecurityChangePassword,
Procedure::SIG_SPEC{
{"current_password", {0, lgraph_api::LGraphType::STRING}},
Expand Down
4 changes: 4 additions & 0 deletions src/server/bolt_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ std::function<void(bolt::BoltConnection &conn, bolt::BoltMsg msg,
session->python_driver = true;
}
}
if (principal == lgraph::_detail::DEFAULT_ADMIN_NAME &&
credentials == lgraph::_detail::DEFAULT_ADMIN_PASS) {
session->using_default_user_password = true;
}
session->state = SessionState::READY;
session->user = principal;
session->fsm_thread = std::thread(BoltFSM, conn.shared_from_this());
Expand Down
1 change: 1 addition & 0 deletions src/server/bolt_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct BoltSession {
BlockingQueue<BoltMsgDetail> msgs;
std::thread fsm_thread;
bool python_driver = false;
bool using_default_user_password = false;
};

} // namespace bolt

0 comments on commit 179a9f7

Please sign in to comment.