Skip to content

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

Log warning when search only API key is set via configuration.

kishorenc0a1b28b5018d
diff --git a/include/config.h b/include/config.h
index a6c8c46e..e2cf4c73 100644
--- a/include/config.h
+++ b/include/config.h
@@ -12,6 +12,9 @@ private:
std::string api_key;
+ // @deprecated
+ std::string search_only_api_key;
+
std::string api_address;
uint32_t api_port;
@@ -55,6 +58,11 @@ public:
this->api_key = api_key;
}
+ // @deprecated
+ 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;
}
@@ -97,6 +105,11 @@ public:
return this->api_key;
}
+ // @deprecated
+ std::string get_search_only_api_key() const {
+ return this->search_only_api_key;
+ }
+
std::string get_api_address() const {
return this->api_address;
}
@@ -156,6 +169,9 @@ public:
this->log_dir = get_env("TYPESENSE_LOG_DIR");
this->api_key = get_env("TYPESENSE_API_KEY");
+ // @deprecated
+ 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");
}
@@ -222,6 +238,11 @@ public:
this->api_key = reader.Get("server", "api-key", "");
}
+ // @deprecated
+ 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", "");
}
@@ -280,6 +301,11 @@ public:
this->api_key = options.get<std::string>("api-key");
}
+ // @deprecated
+ 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");
}
diff --git a/src/typesense_server_utils.cpp b/src/typesense_server_utils.cpp
index a54f7756..1a940518 100644
--- a/src/typesense_server_utils.cpp
+++ b/src/typesense_server_utils.cpp
@@ -101,6 +101,7 @@ 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', "[DEPRECATED: use API key management end-point] 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);
@@ -290,6 +291,12 @@ int run_server(const Config & config, const std::string & version, void (*master
return 1;
}
+ if(!config.get_search_only_api_key().empty()) {
+ LOG(WARNING) << "!!!! WARNING !!!!";
+ LOG(WARNING) << "The --search-only-api-key has been deprecated. "
+ "The API key generation end-point should be used for generating keys with specific ACL.";
+ }
+
std::string data_dir = config.get_data_dir();
std::string db_dir = config.get_data_dir() + "/db";
std::string state_dir = config.get_data_dir() + "/state";