Merge pull request #10918 from Budibase/budi-5262/support_pg_client_cert
Budi 5262 - Support pg client cert
This commit is contained in:
commit
df3afe2a7c
|
@ -22,6 +22,7 @@
|
|||
import ImportRestQueriesModal from "components/backend/DatasourceNavigator/modals/ImportRestQueriesModal.svelte"
|
||||
import { API } from "api"
|
||||
import { DatasourceFeature } from "@budibase/types"
|
||||
import Spinner from "components/common/Spinner.svelte"
|
||||
|
||||
const querySchema = {
|
||||
name: {},
|
||||
|
@ -33,6 +34,7 @@
|
|||
let isValid = true
|
||||
let integration, baseDatasource, datasource
|
||||
let queryList
|
||||
let loading = false
|
||||
|
||||
$: baseDatasource = $datasources.selected
|
||||
$: queryList = $queries.list.filter(
|
||||
|
@ -65,9 +67,11 @@
|
|||
}
|
||||
|
||||
const saveDatasource = async () => {
|
||||
loading = true
|
||||
if (integration.features?.[DatasourceFeature.CONNECTION_CHECKING]) {
|
||||
const valid = await validateConfig()
|
||||
if (!valid) {
|
||||
loading = false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +86,8 @@
|
|||
baseDatasource = cloneDeep(datasource)
|
||||
} catch (err) {
|
||||
notifications.error(`Error saving datasource: ${err}`)
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,8 +125,17 @@
|
|||
<Divider />
|
||||
<div class="config-header">
|
||||
<Heading size="S">Configuration</Heading>
|
||||
<Button disabled={!changed || !isValid} cta on:click={saveDatasource}>
|
||||
Save
|
||||
<Button
|
||||
disabled={!changed || !isValid || loading}
|
||||
cta
|
||||
on:click={saveDatasource}
|
||||
>
|
||||
<div class="save-button-content">
|
||||
{#if loading}
|
||||
<Spinner size="10">Save</Spinner>
|
||||
{/if}
|
||||
Save
|
||||
</div>
|
||||
</Button>
|
||||
</div>
|
||||
<IntegrationConfigForm
|
||||
|
@ -216,4 +231,10 @@
|
|||
flex-direction: column;
|
||||
gap: var(--spacing-m);
|
||||
}
|
||||
|
||||
.save-button-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-s);
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -20,7 +20,7 @@ import Sql from "./base/sql"
|
|||
import { PostgresColumn } from "./base/types"
|
||||
import { escapeDangerousCharacters } from "../utilities"
|
||||
|
||||
import { Client, types } from "pg"
|
||||
import { Client, ClientConfig, types } from "pg"
|
||||
|
||||
// Return "date" and "timestamp" types as plain strings.
|
||||
// This lets us reference the original stored timezone.
|
||||
|
@ -42,6 +42,8 @@ interface PostgresConfig {
|
|||
schema: string
|
||||
ssl?: boolean
|
||||
ca?: string
|
||||
clientKey?: string
|
||||
clientCert?: string
|
||||
rejectUnauthorized?: boolean
|
||||
}
|
||||
|
||||
|
@ -98,6 +100,19 @@ const SCHEMA: Integration = {
|
|||
required: false,
|
||||
},
|
||||
ca: {
|
||||
display: "Server CA",
|
||||
type: DatasourceFieldType.LONGFORM,
|
||||
default: false,
|
||||
required: false,
|
||||
},
|
||||
clientKey: {
|
||||
display: "Client key",
|
||||
type: DatasourceFieldType.LONGFORM,
|
||||
default: false,
|
||||
required: false,
|
||||
},
|
||||
clientCert: {
|
||||
display: "Client cert",
|
||||
type: DatasourceFieldType.LONGFORM,
|
||||
default: false,
|
||||
required: false,
|
||||
|
@ -144,12 +159,14 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
|||
super(SqlClient.POSTGRES)
|
||||
this.config = config
|
||||
|
||||
let newConfig = {
|
||||
let newConfig: ClientConfig = {
|
||||
...this.config,
|
||||
ssl: this.config.ssl
|
||||
? {
|
||||
rejectUnauthorized: this.config.rejectUnauthorized,
|
||||
ca: this.config.ca,
|
||||
key: this.config.clientKey,
|
||||
cert: this.config.clientCert,
|
||||
}
|
||||
: undefined,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue