Browse Source

fix: hash API keys with bcrypt in seed (was plaintext)

clawPi4Bot 2 tháng trước cách đây
mục cha
commit
e54c51d1e5
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      apps/api-server/src/db/seed.ts

+ 2 - 1
apps/api-server/src/db/seed.ts

@@ -65,7 +65,8 @@ async function seed() {
 
 
   for (const d of deviceNames) {
   for (const d of deviceNames) {
     const deviceId = d.serial  // ID = serial for easy POC testing
     const deviceId = d.serial  // ID = serial for easy POC testing
-    const apiKeyHash = `dev-api-key-${d.serial.toLowerCase()}`
+    const apiKeyPlain = `dev-api-key-${d.serial.toLowerCase()}`
+    const apiKeyHash = await bcrypt.hash(apiKeyPlain, 10)
     await db.insert(devices).values({
     await db.insert(devices).values({
       id: deviceId,
       id: deviceId,
       orgId,
       orgId,