mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Add encrypt option to MS SQL questions (#6746)
This commit is contained in:
@@ -50,6 +50,13 @@ const password = (): Record<string, string> => ({
|
||||
mask: '*',
|
||||
});
|
||||
|
||||
const encrypt = (): Record<string, string | boolean> => ({
|
||||
type: 'confirm',
|
||||
name: 'options__encrypt',
|
||||
message: 'Encrypt Connection:',
|
||||
default: false,
|
||||
});
|
||||
|
||||
const ssl = (): Record<string, string | boolean> => ({
|
||||
type: 'confirm',
|
||||
name: 'ssl',
|
||||
@@ -62,5 +69,5 @@ export const databaseQuestions = {
|
||||
mysql: [host, port, database, user, password],
|
||||
pg: [host, port, database, user, password, ssl],
|
||||
oracledb: [host, port, database, user, password],
|
||||
mssql: [host, port, database, user, password],
|
||||
mssql: [host, port, database, user, password, encrypt],
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ export type Credentials = {
|
||||
user?: string;
|
||||
password?: string;
|
||||
ssl?: boolean;
|
||||
options__encrypt?: boolean;
|
||||
};
|
||||
export default function createDBConnection(
|
||||
client: 'sqlite3' | 'mysql' | 'pg' | 'oracledb' | 'mssql',
|
||||
@@ -23,26 +24,26 @@ export default function createDBConnection(
|
||||
filename: filename as string,
|
||||
};
|
||||
} else {
|
||||
if (client !== 'pg') {
|
||||
const { host, port, database, user, password } = credentials as Credentials;
|
||||
const { host, port, database, user, password } = credentials as Credentials;
|
||||
|
||||
connection = {
|
||||
host: host,
|
||||
port: Number(port),
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
};
|
||||
} else {
|
||||
const { host, port, database, user, password, ssl } = credentials as Credentials;
|
||||
connection = {
|
||||
host: host,
|
||||
port: Number(port),
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
};
|
||||
|
||||
connection = {
|
||||
host: host,
|
||||
port: Number(port),
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
ssl: ssl,
|
||||
if (client === 'pg') {
|
||||
const { ssl } = credentials as Credentials;
|
||||
connection['ssl'] = ssl;
|
||||
}
|
||||
|
||||
if (client === 'mssql') {
|
||||
const { options__encrypt } = credentials as Credentials;
|
||||
|
||||
(connection as Knex.MsSqlConnectionConfig)['options'] = {
|
||||
encrypt: options__encrypt,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user