플로우 로그기능 수정
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import { Pool as PgPool } from "pg";
|
||||
import * as mysql from "mysql2/promise";
|
||||
import db from "../database/db";
|
||||
import { CredentialEncryption } from "../utils/credentialEncryption";
|
||||
import { PasswordEncryption } from "../utils/passwordEncryption";
|
||||
import {
|
||||
getConnectionTestQuery,
|
||||
getPlaceholder,
|
||||
@@ -31,24 +31,13 @@ interface ExternalDbConnection {
|
||||
// 외부 DB 연결 풀 캐시 (타입별로 다른 풀 객체)
|
||||
const connectionPools = new Map<number, any>();
|
||||
|
||||
// 비밀번호 복호화 유틸
|
||||
const credentialEncryption = new CredentialEncryption(
|
||||
process.env.ENCRYPTION_SECRET_KEY || "default-secret-key-change-in-production"
|
||||
);
|
||||
|
||||
/**
|
||||
* 외부 DB 연결 정보 조회
|
||||
*/
|
||||
async function getExternalConnection(
|
||||
connectionId: number
|
||||
): Promise<ExternalDbConnection | null> {
|
||||
const query = `
|
||||
SELECT
|
||||
id, connection_name, db_type, host, port,
|
||||
database_name, username, encrypted_password, is_active
|
||||
FROM external_db_connections
|
||||
WHERE id = $1 AND is_active = true
|
||||
`;
|
||||
const query = `SELECT * FROM external_db_connections WHERE id = $1 AND is_active = 'Y'`;
|
||||
|
||||
const result = await db.query(query, [connectionId]);
|
||||
|
||||
@@ -58,13 +47,14 @@ async function getExternalConnection(
|
||||
|
||||
const row = result[0];
|
||||
|
||||
// 비밀번호 복호화
|
||||
// 비밀번호 복호화 (암호화된 비밀번호는 password 컬럼에 저장됨)
|
||||
let decryptedPassword = "";
|
||||
try {
|
||||
decryptedPassword = credentialEncryption.decrypt(row.encrypted_password);
|
||||
decryptedPassword = PasswordEncryption.decrypt(row.password);
|
||||
} catch (error) {
|
||||
console.error(`비밀번호 복호화 실패 (ID: ${connectionId}):`, error);
|
||||
throw new Error("외부 DB 비밀번호 복호화에 실패했습니다");
|
||||
// 복호화 실패 시 원본 비밀번호 사용 (fallback)
|
||||
decryptedPassword = row.password;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user