Merge pull request #8386 from chaoticefx/elasticsearch-rejectUnauthorized
Custom ssl config for Elasticsearch datasource
This commit is contained in:
commit
bf35717449
|
@ -5,10 +5,13 @@ import {
|
|||
IntegrationBase,
|
||||
} from "@budibase/types"
|
||||
|
||||
const { Client } = require("@elastic/elasticsearch")
|
||||
import { Client, ClientOptions } from "@elastic/elasticsearch"
|
||||
|
||||
interface ElasticsearchConfig {
|
||||
url: string
|
||||
ssl?: boolean
|
||||
ca?: string
|
||||
rejectUnauthorized?: boolean
|
||||
}
|
||||
|
||||
const SCHEMA: Integration = {
|
||||
|
@ -23,6 +26,21 @@ const SCHEMA: Integration = {
|
|||
required: true,
|
||||
default: "http://localhost:9200",
|
||||
},
|
||||
ssl: {
|
||||
type: DatasourceFieldType.BOOLEAN,
|
||||
default: false,
|
||||
required: false,
|
||||
},
|
||||
rejectUnauthorized: {
|
||||
type: DatasourceFieldType.BOOLEAN,
|
||||
default: true,
|
||||
required: false,
|
||||
},
|
||||
ca: {
|
||||
type: DatasourceFieldType.LONGFORM,
|
||||
default: false,
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
query: {
|
||||
create: {
|
||||
|
@ -81,7 +99,19 @@ class ElasticSearchIntegration implements IntegrationBase {
|
|||
|
||||
constructor(config: ElasticsearchConfig) {
|
||||
this.config = config
|
||||
this.client = new Client({ node: config.url })
|
||||
|
||||
const clientConfig: ClientOptions = {
|
||||
node: this.config.url,
|
||||
}
|
||||
|
||||
if (this.config.ssl) {
|
||||
clientConfig.ssl = {
|
||||
rejectUnauthorized: this.config.rejectUnauthorized,
|
||||
ca: this.config.ca || undefined,
|
||||
}
|
||||
}
|
||||
|
||||
this.client = new Client(clientConfig)
|
||||
}
|
||||
|
||||
async create(query: { index: string; json: object }) {
|
||||
|
|
Loading…
Reference in New Issue