diff --git a/include/collection_manager.h b/include/collection_manager.h index 49f5f0c0..fb08bccd 100644 --- a/include/collection_manager.h +++ b/include/collection_manager.h @@ -58,11 +58,7 @@ public: CollectionManager(CollectionManager const&) = delete; void operator=(CollectionManager const&) = delete; - void init(Store *store, - const size_t default_num_indices, - const std::string & auth_key, - const std::string & search_only_auth_key - ); + void init(Store *store, const size_t default_num_indices, const std::string & auth_key); Option load(const size_t init_batch_size=1000); diff --git a/include/config.h b/include/config.h index cf5c6468..a6c8c46e 100644 --- a/include/config.h +++ b/include/config.h @@ -11,7 +11,6 @@ private: std::string log_dir; std::string api_key; - std::string search_only_api_key; std::string api_address; uint32_t api_port; @@ -56,10 +55,6 @@ public: this->api_key = api_key; } - void set_search_only_api_key(const std::string & search_only_api_key) { - this->search_only_api_key = search_only_api_key; - } - void set_listen_address(const std::string & listen_address) { this->api_address = listen_address; } @@ -102,10 +97,6 @@ public: return this->api_key; } - std::string get_search_only_api_key() const { - return this->search_only_api_key; - } - std::string get_api_address() const { return this->api_address; } @@ -165,8 +156,6 @@ public: this->log_dir = get_env("TYPESENSE_LOG_DIR"); this->api_key = get_env("TYPESENSE_API_KEY"); - this->search_only_api_key = get_env("TYPESENSE_SEARCH_ONLY_API_KEY"); - if(!get_env("TYPESENSE_LISTEN_ADDRESS").empty()) { this->api_address = get_env("TYPESENSE_LISTEN_ADDRESS"); } @@ -233,10 +222,6 @@ public: this->api_key = reader.Get("server", "api-key", ""); } - if(reader.Exists("server", "search-only-api-key")) { - this->search_only_api_key = reader.Get("server", "search-only-api-key", ""); - } - if(reader.Exists("server", "listen-address")) { this->api_address = reader.Get("server", "listen-address", ""); } @@ -295,10 +280,6 @@ public: this->api_key = options.get("api-key"); } - if(options.exist("search-only-api-key")) { - this->search_only_api_key = options.get("search-only-api-key"); - } - if(options.exist("listen-address")) { this->api_address = options.get("listen-address"); } diff --git a/src/collection_manager.cpp b/src/collection_manager.cpp index adf60e8a..df8b5f3e 100644 --- a/src/collection_manager.cpp +++ b/src/collection_manager.cpp @@ -50,11 +50,9 @@ void CollectionManager::add_to_collections(Collection* collection) { void CollectionManager::init(Store *store, const size_t default_num_indices, - const std::string & auth_key, - const std::string & search_only_auth_key) { + const std::string & auth_key) { this->store = store; this->bootstrap_auth_key = auth_key; - this->bootstrap_search_only_auth_key = search_only_auth_key; this->default_num_indices = default_num_indices; auth_manager.init(store); @@ -216,11 +214,6 @@ bool CollectionManager::auth_key_matches(const std::string& auth_key_sent, return false; } - // check with bootstrap search only auth key - if(action == "documents:search" && bootstrap_search_only_auth_key == auth_key_sent) { - return true; - } - // check with bootstrap auth key if(bootstrap_auth_key == auth_key_sent) { return true; diff --git a/src/typesense_server_utils.cpp b/src/typesense_server_utils.cpp index 858937f6..a54f7756 100644 --- a/src/typesense_server_utils.cpp +++ b/src/typesense_server_utils.cpp @@ -101,7 +101,6 @@ void init_cmdline_options(cmdline::parser & options, int argc, char **argv) { options.add("data-dir", 'd', "Directory where data will be stored.", true); options.add("api-key", 'a', "API key that allows all operations.", true); - options.add("search-only-api-key", 's', "API key that allows only searches.", false); options.add("api-address", '\0', "Address to which Typesense API service binds.", false, "0.0.0.0"); options.add("api-port", '\0', "Port on which Typesense API service listens.", false, 8108); @@ -318,7 +317,7 @@ int run_server(const Config & config, const std::string & version, void (*master Store store(db_dir); CollectionManager & collectionManager = CollectionManager::get_instance(); collectionManager.init(&store, config.get_indices_per_collection(), - config.get_api_key(), config.get_search_only_api_key()); + config.get_api_key()); curl_global_init(CURL_GLOBAL_SSL); HttpClient & httpClient = HttpClient::get_instance(); diff --git a/test/collection_faceting_test.cpp b/test/collection_faceting_test.cpp index 796d8e8c..72cb1f05 100644 --- a/test/collection_faceting_test.cpp +++ b/test/collection_faceting_test.cpp @@ -20,7 +20,7 @@ protected: system(("rm -rf "+state_dir_path+" && mkdir -p "+state_dir_path).c_str()); store = new Store(state_dir_path); - collectionManager.init(store, 4, "auth_key", "search_auth_key"); + collectionManager.init(store, 4, "auth_key"); collectionManager.load(); } diff --git a/test/collection_manager_test.cpp b/test/collection_manager_test.cpp index 16b15ba7..f2b1f03a 100644 --- a/test/collection_manager_test.cpp +++ b/test/collection_manager_test.cpp @@ -20,7 +20,7 @@ protected: system(("rm -rf "+state_dir_path+" && mkdir -p "+state_dir_path).c_str()); store = new Store(state_dir_path); - collectionManager.init(store, 4, "auth_key", "search_auth_key"); + collectionManager.init(store, 4, "auth_key"); collectionManager.load(); search_fields = { @@ -211,7 +211,7 @@ TEST_F(CollectionManagerTest, RestoreRecordsOnRestart) { // create a new collection manager to ensure that it restores the records from the disk backed store CollectionManager & collectionManager2 = CollectionManager::get_instance(); - collectionManager2.init(store, 4, "auth_key", "search_auth_key"); + collectionManager2.init(store, 4, "auth_key"); collectionManager2.load(); collection1 = collectionManager2.get_collection("collection1"); @@ -279,7 +279,7 @@ TEST_F(CollectionManagerTest, Symlinking) { std::string state_dir_path = "/tmp/typesense_test/cmanager_test_db"; system(("rm -rf "+state_dir_path+" && mkdir -p "+state_dir_path).c_str()); Store *store = new Store(state_dir_path); - cmanager.init(store, 4, "auth_key", "search_auth_key"); + cmanager.init(store, 4, "auth_key"); cmanager.load(); // try resolving on a blank slate @@ -345,7 +345,7 @@ TEST_F(CollectionManagerTest, Symlinking) { // should be able to restore state on init CollectionManager & cmanager2 = CollectionManager::get_instance(); - cmanager2.init(store, 4, "auth_key", "search_auth_key"); + cmanager2.init(store, 4, "auth_key"); cmanager2.load(); collection_option = cmanager2.resolve_symlink("company"); diff --git a/test/collection_override_test.cpp b/test/collection_override_test.cpp index 3a73f567..0aa386ee 100644 --- a/test/collection_override_test.cpp +++ b/test/collection_override_test.cpp @@ -18,7 +18,7 @@ protected: system(("rm -rf "+state_dir_path+" && mkdir -p "+state_dir_path).c_str()); store = new Store(state_dir_path); - collectionManager.init(store, 1, "auth_key", "search_auth_key"); + collectionManager.init(store, 1, "auth_key"); collectionManager.load(); std::ifstream infile(std::string(ROOT_DIR)+"test/multi_field_documents.jsonl"); diff --git a/test/collection_sorting_test.cpp b/test/collection_sorting_test.cpp index ed275529..93caff5b 100644 --- a/test/collection_sorting_test.cpp +++ b/test/collection_sorting_test.cpp @@ -20,7 +20,7 @@ protected: system(("rm -rf "+state_dir_path+" && mkdir -p "+state_dir_path).c_str()); store = new Store(state_dir_path); - collectionManager.init(store, 4, "auth_key", "search_auth_key"); + collectionManager.init(store, 4, "auth_key"); collectionManager.load(); } diff --git a/test/collection_test.cpp b/test/collection_test.cpp index 98d1c70b..2660f37d 100644 --- a/test/collection_test.cpp +++ b/test/collection_test.cpp @@ -20,7 +20,7 @@ protected: system(("rm -rf "+state_dir_path+" && mkdir -p "+state_dir_path).c_str()); store = new Store(state_dir_path); - collectionManager.init(store, 4, "auth_key", "search_auth_key"); + collectionManager.init(store, 4, "auth_key"); collectionManager.load(); std::ifstream infile(std::string(ROOT_DIR)+"test/documents.jsonl"); diff --git a/test/config_test.cpp b/test/config_test.cpp index 82c0bdf0..707eaece 100644 --- a/test/config_test.cpp +++ b/test/config_test.cpp @@ -143,7 +143,6 @@ TEST(ConfigTest, CmdLineArgsOverrideConfigFileAndEnvVars) { putenv((char*)"TYPESENSE_LISTEN_PORT=9090"); putenv((char*)"TYPESENSE_LISTEN_ADDRESS=127.0.0.1"); putenv((char*)"TYPESENSE_ENABLE_CORS=TRUE"); - putenv((char*)"TYPESENSE_SEARCH_ONLY_API_KEY=envsecret"); std::vector argv = get_argv(args); init_cmdline_options(options, argv.size() - 1, argv.data()); @@ -160,5 +159,5 @@ TEST(ConfigTest, CmdLineArgsOverrideConfigFileAndEnvVars) { ASSERT_EQ(9090, config.get_api_port()); ASSERT_EQ(true, config.get_enable_cors()); ASSERT_EQ("192.168.10.10", config.get_api_address()); - ASSERT_EQ("supersecret", config.get_search_only_api_key()); + ASSERT_EQ("abcd", config.get_api_key()); // cli parameter overrides file config } \ No newline at end of file diff --git a/test/valid_sparse_config.ini b/test/valid_sparse_config.ini index 5991c603..977c3bde 100644 --- a/test/valid_sparse_config.ini +++ b/test/valid_sparse_config.ini @@ -1,5 +1,5 @@ ; Sample Typesense Configuration [server] -search-only-api-key = supersecret +api-key = supersecret listen-address = localhost