Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Add logging for auth key handling.
kishorenc1f726d747ab5
diff --git a/src/auth_manager.cpp b/src/auth_manager.cppindex fe2f3e37..e4e6fbd7 100644--- a/src/auth_manager.cpp+++ b/src/auth_manager.cpp@@ -4,6 +4,8 @@constexpr const char* AuthManager::DOCUMENTS_SEARCH_ACTION;Option<bool> AuthManager::init(Store *store) {+ LOG(INFO) << "AuthManager::init()";+this->store = store;std::string next_api_key_id_str;@@ -22,6 +24,8 @@ Option<bool> AuthManager::init(Store *store) {std::vector<std::string> api_key_json_strs;store->scan_fill(API_KEYS_PREFIX, api_key_json_strs);+ LOG(INFO) << "Indexing " << api_key_json_strs.size() << " API key(s) found on disk.";+for(auto & api_key_json_str: api_key_json_strs) {api_key_t api_key;Option<bool> load_op = api_key.load(api_key_json_str);@@ -80,6 +84,8 @@ Option<api_key_t> AuthManager::get_key(uint32_t id, bool truncate_value) {}Option<api_key_t> AuthManager::create_key(api_key_t& api_key) {+ LOG(INFO) << "AuthManager::create_key()";+if(api_keys.count(api_key.value) != 0) {return Option<api_key_t>(409, "API key generation conflict.");}@@ -124,6 +130,9 @@ uint32_t AuthManager::get_next_api_key_id() {bool AuthManager::authenticate(const std::string& req_api_key, const std::string& action,const std::string& collection, std::map<std::string, std::string>& params) {+ // FIXME:+ LOG(INFO) << "AuthManager::authenticate()";+if(req_api_key.size() > KEY_LEN) {// scoped API key: validate and if valid, extract paramsOption<std::string> params_op = params_from_scoped_key(req_api_key, action, collection);@@ -161,6 +170,9 @@ bool AuthManager::authenticate(const std::string& req_api_key, const std::stringreturn true;}+ // FIXME:+ LOG(INFO) << "api_keys.size() = " << api_keys.size();+if(api_keys.count(req_api_key) == 0) {return false;}diff --git a/src/collection_manager.cpp b/src/collection_manager.cppindex 416d770d..f4810be7 100644--- a/src/collection_manager.cpp+++ b/src/collection_manager.cpp@@ -67,6 +67,8 @@ void CollectionManager::init(Store *store,}Option<bool> CollectionManager::load(const size_t init_batch_size) {+ LOG(INFO) << "CollectionManager::load()";+Option<bool> auth_init_op = auth_manager.init(store);if(!auth_init_op.ok()) {LOG(ERROR) << "Auth manager init failed, error=" << auth_init_op.error();diff --git a/src/core_api.cpp b/src/core_api.cppindex 58275651..ca0ba7fe 100644--- a/src/core_api.cpp+++ b/src/core_api.cpp@@ -983,6 +983,8 @@ bool get_keys(http_req &req, http_res &res) {}bool post_create_key(http_req &req, http_res &res) {+ LOG(INFO) << "post_create_key";+CollectionManager & collectionManager = CollectionManager::get_instance();AuthManager &auth_manager = collectionManager.getAuthManager();diff --git a/src/raft_server.cpp b/src/raft_server.cppindex fc52ee2e..8ab9fe39 100644--- a/src/raft_server.cpp+++ b/src/raft_server.cpp@@ -223,6 +223,8 @@ void ReplicationState::read(http_res* response) {}void* ReplicationState::save_snapshot(void* arg) {+ LOG(INFO) << "save_snapshot called";+SnapshotArg* sa = static_cast<SnapshotArg*>(arg);std::unique_ptr<SnapshotArg> arg_guard(sa);brpc::ClosureGuard done_guard(sa->done);@@ -253,6 +255,8 @@ void* ReplicationState::save_snapshot(void* arg) {}}+ LOG(INFO) << "save_snapshot done";+return nullptr;}