mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 12:53:58 +00:00
password mode saveRaw
This commit is contained in:
@@ -43,7 +43,12 @@ function getEncryptor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function encryptConnection(connection) {
|
function encryptConnection(connection) {
|
||||||
if (connection && connection.password && !connection.password.startsWith('crypt:')) {
|
if (
|
||||||
|
connection &&
|
||||||
|
connection.password &&
|
||||||
|
!connection.password.startsWith('crypt:') &&
|
||||||
|
connection.passwordMode != 'saveRaw'
|
||||||
|
) {
|
||||||
return {
|
return {
|
||||||
...connection,
|
...connection,
|
||||||
password: 'crypt:' + getEncryptor().encrypt(connection.password),
|
password: 'crypt:' + getEncryptor().encrypt(connection.password),
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import { FormProvider, useForm } from '../utility/FormProvider';
|
|||||||
function DriverFields({ extensions }) {
|
function DriverFields({ extensions }) {
|
||||||
const { values, setFieldValue } = useForm();
|
const { values, setFieldValue } = useForm();
|
||||||
const { authType, engine } = values;
|
const { authType, engine } = values;
|
||||||
const driver = extensions.drivers.find(x => x.engine == engine);
|
const driver = extensions.drivers.find((x) => x.engine == engine);
|
||||||
// const { authTypes } = driver || {};
|
// const { authTypes } = driver || {};
|
||||||
const [authTypes, setAuthTypes] = React.useState(null);
|
const [authTypes, setAuthTypes] = React.useState(null);
|
||||||
const currentAuthType = authTypes && authTypes.find(x => x.name == authType);
|
const currentAuthType = authTypes && authTypes.find((x) => x.name == authType);
|
||||||
|
|
||||||
const loadAuthTypes = async () => {
|
const loadAuthTypes = async () => {
|
||||||
const resp = await axios.post('plugins/auth-types', { engine });
|
const resp = await axios.post('plugins/auth-types', { engine });
|
||||||
@@ -29,7 +29,7 @@ function DriverFields({ extensions }) {
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
setAuthTypes(null);
|
setAuthTypes(null);
|
||||||
loadAuthTypes()
|
loadAuthTypes();
|
||||||
}, [values.engine]);
|
}, [values.engine]);
|
||||||
|
|
||||||
if (!driver) return null;
|
if (!driver) return null;
|
||||||
@@ -39,7 +39,7 @@ function DriverFields({ extensions }) {
|
|||||||
<>
|
<>
|
||||||
{!!authTypes && (
|
{!!authTypes && (
|
||||||
<FormSelectField label="Authentication" name="authType">
|
<FormSelectField label="Authentication" name="authType">
|
||||||
{authTypes.map(auth => (
|
{authTypes.map((auth) => (
|
||||||
<option value={auth.name} key={auth.name}>
|
<option value={auth.name} key={auth.name}>
|
||||||
{auth.title}
|
{auth.title}
|
||||||
</option>
|
</option>
|
||||||
@@ -50,6 +50,12 @@ function DriverFields({ extensions }) {
|
|||||||
<FormTextField label="Port" name="port" disabled={disabledFields.includes('port')} />
|
<FormTextField label="Port" name="port" disabled={disabledFields.includes('port')} />
|
||||||
<FormTextField label="User" name="user" disabled={disabledFields.includes('user')} />
|
<FormTextField label="User" name="user" disabled={disabledFields.includes('user')} />
|
||||||
<FormPasswordField label="Password" name="password" disabled={disabledFields.includes('password')} />
|
<FormPasswordField label="Password" name="password" disabled={disabledFields.includes('password')} />
|
||||||
|
{!disabledFields.includes('password') && (
|
||||||
|
<FormSelectField label="Password mode" name="passwordMode">
|
||||||
|
<option value="saveEncrypted">Save and encrypt</option>
|
||||||
|
<option value="saveRaw">Save raw (UNSAFE!!)</option>
|
||||||
|
</FormSelectField>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -60,7 +66,7 @@ export default function ConnectionModal({ modalState, connection = undefined })
|
|||||||
const [isTesting, setIsTesting] = React.useState(false);
|
const [isTesting, setIsTesting] = React.useState(false);
|
||||||
const testIdRef = React.useRef(0);
|
const testIdRef = React.useRef(0);
|
||||||
|
|
||||||
const handleTest = async values => {
|
const handleTest = async (values) => {
|
||||||
setIsTesting(true);
|
setIsTesting(true);
|
||||||
testIdRef.current += 1;
|
testIdRef.current += 1;
|
||||||
const testid = testIdRef.current;
|
const testid = testIdRef.current;
|
||||||
@@ -76,7 +82,7 @@ export default function ConnectionModal({ modalState, connection = undefined })
|
|||||||
setIsTesting(false);
|
setIsTesting(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async values => {
|
const handleSubmit = async (values) => {
|
||||||
axios.post('connections/save', values);
|
axios.post('connections/save', values);
|
||||||
modalState.close();
|
modalState.close();
|
||||||
};
|
};
|
||||||
@@ -86,8 +92,8 @@ export default function ConnectionModal({ modalState, connection = undefined })
|
|||||||
<FormProvider initialValues={connection || { server: 'localhost', engine: 'mssql@dbgate-plugin-mssql' }}>
|
<FormProvider initialValues={connection || { server: 'localhost', engine: 'mssql@dbgate-plugin-mssql' }}>
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
<FormSelectField label="Database engine" name="engine">
|
<FormSelectField label="Database engine" name="engine">
|
||||||
<option value=""></option>
|
<option value="(select driver)"></option>
|
||||||
{extensions.drivers.map(driver => (
|
{extensions.drivers.map((driver) => (
|
||||||
<option value={driver.engine} key={driver.engine}>
|
<option value={driver.engine} key={driver.engine}>
|
||||||
{driver.title}
|
{driver.title}
|
||||||
</option>
|
</option>
|
||||||
|
|||||||
Reference in New Issue
Block a user