Insist on API key authentication even for search end-point.

Server can be started with a separate `--search-only-api-key` argument for exposing this key on the JS client.
This commit is contained in:
kishorenc 2020-03-06 07:46:28 +05:30
parent 6bb6f2f4b8
commit c7eb19ca46
2 changed files with 3 additions and 3 deletions

View File

@ -71,7 +71,7 @@ public:
bool auth_key_matches(std::string auth_key_sent);
bool search_only_auth_key_matches(std::string auth_key_sent);
bool search_only_auth_key_matches(const std::string & auth_key_sent);
Option<Collection*> create_collection(const std::string name, const std::vector<field> & fields,
const std::string & default_sorting_field,

View File

@ -200,8 +200,8 @@ bool CollectionManager::auth_key_matches(std::string auth_key_sent) {
return (auth_key == auth_key_sent);
}
bool CollectionManager::search_only_auth_key_matches(std::string auth_key_sent) {
return (search_only_auth_key == auth_key_sent);
bool CollectionManager::search_only_auth_key_matches(const std::string & auth_key_sent) {
return !auth_key_sent.empty() && (search_only_auth_key == auth_key_sent);
}
Option<Collection*> CollectionManager::create_collection(const std::string name, const std::vector<field> & fields,