feat: es auth (#156)
This commit is contained in:
@@ -58,7 +58,11 @@
|
||||
"type": "SEARCH_DRIVER",
|
||||
"elasticsearch": {
|
||||
"endpoint": "SEARCH_ES_ENDPOINT",
|
||||
"flushInterval": "SEARCH_ES_FLUSHINTERVAL"
|
||||
"flushInterval": "SEARCH_ES_FLUSHINTERVAL",
|
||||
"useAuth": "SEARCH_ES_USE_AUTH",
|
||||
"username": "SEARCH_ES_USERNAME",
|
||||
"password": "SEARCH_ES_PASSWORD"
|
||||
|
||||
}
|
||||
},
|
||||
"storage": {
|
||||
|
||||
+11
-2
@@ -40,12 +40,21 @@ export default class ElasticSearch extends SearchAdapter implements SearchAdapte
|
||||
|
||||
public async connect() {
|
||||
try {
|
||||
this.client = new Client({
|
||||
const clientOptions: any = {
|
||||
node: this.configuration.endpoint,
|
||||
ssl: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
if (this.configuration.useAuth) {
|
||||
clientOptions.auth = {
|
||||
username: this.configuration.username,
|
||||
password: this.configuration.password,
|
||||
};
|
||||
}
|
||||
|
||||
this.client = new Client(clientOptions);
|
||||
} catch (e) {
|
||||
logger.error(`Unable to connect to ElasticSearch at ${this.configuration.endpoint}`);
|
||||
}
|
||||
|
||||
@@ -67,6 +67,9 @@ export interface SearchServiceAPI extends TdriveServiceProvider {
|
||||
export type SearchConfiguration = {
|
||||
type?: false | "elasticsearch" | "mongodb";
|
||||
elasticsearch?: {
|
||||
useAuth: boolean;
|
||||
username?: string;
|
||||
password?: string;
|
||||
endpoint: string;
|
||||
flushInterval: number; //In milliseconds
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user