mirror of
https://github.com/typesense/typesense.git
synced 2025-05-19 21:22:25 +08:00
Remove search-only-api-key server argument.
The API key generation end-point should be use for generating keys with specific ACL.
This commit is contained in:
parent
59131d1333
commit
377394e793
@ -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<bool> load(const size_t init_batch_size=1000);
|
||||
|
||||
|
@ -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<std::string>("api-key");
|
||||
}
|
||||
|
||||
if(options.exist("search-only-api-key")) {
|
||||
this->search_only_api_key = options.get<std::string>("search-only-api-key");
|
||||
}
|
||||
|
||||
if(options.exist("listen-address")) {
|
||||
this->api_address = options.get<std::string>("listen-address");
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -101,7 +101,6 @@ void init_cmdline_options(cmdline::parser & options, int argc, char **argv) {
|
||||
|
||||
options.add<std::string>("data-dir", 'd', "Directory where data will be stored.", true);
|
||||
options.add<std::string>("api-key", 'a', "API key that allows all operations.", true);
|
||||
options.add<std::string>("search-only-api-key", 's', "API key that allows only searches.", false);
|
||||
|
||||
options.add<std::string>("api-address", '\0', "Address to which Typesense API service binds.", false, "0.0.0.0");
|
||||
options.add<uint32_t>("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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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<char*> 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
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
; Sample Typesense Configuration
|
||||
|
||||
[server]
|
||||
search-only-api-key = supersecret
|
||||
api-key = supersecret
|
||||
listen-address = localhost
|
||||
|
Loading…
x
Reference in New Issue
Block a user