feat: es auth (#156)
This commit is contained in:
+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