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