BT San Technology

12 January 2026

API keys and environment variables: keeping web app secrets out of the code

2 min read · Websites and web apps

Illustration: a laptop listing keys with masked values and toggles, beside a locked metal box and a USB key
AI-generated illustration

This guide is available in Thai only.

ค่าตั้งค่าทั่วไปต่างจากข้อมูลลับ ค่าที่ส่งไปเบราว์เซอร์ไม่ถือว่าเก็บเป็นความลับฝั่งเซิร์ฟเวอร์ การออกสิทธิ์ขั้นต่ำ เปลี่ยนกุญแจ และเพิกถอน

ขั้นตอนนำไปใช้

  1. ทำบัญชีข้อมูลลับและเจ้าของแต่ละรายการ
  2. แยกสิทธิ์และชุดข้อมูลลับของแต่ละสภาพแวดล้อม
  3. ตรวจเส้นทางโค้ด ไฟล์สร้าง และบันทึกที่อาจเผยค่า
  4. ซ้อมเปลี่ยนและเพิกถอนโดยตรวจว่าบริการยังทำงานได้

ตัวอย่างผลส่งมอบ

ผลส่งมอบ: ทะเบียนข้อมูลลับที่เก็บเพียงชื่อ ผู้รับผิดชอบ และรอบทบทวน

ประโยชน์

ช่วยควบคุมการเข้าถึงบริการและรับมือเมื่อกุญแจรั่ว

ข้อจำกัดและข้อควรระวัง

ชื่อ environment variable ไม่ทำให้ค่าปลอดภัยอัตโนมัติ ต้องตรวจว่าถูกบรรจุไปที่ใด

แหล่งอ้างอิงเริ่มต้น

  • OWASP — Secrets Management
  • The Twelve-Factor App — Config

References

  1. OWASP — Secrets Management (accessed 2026-11-21)
  2. The Twelve-Factor App — Config (accessed 2026-11-21)

Add us on LINE

Scan with the LINE app on your phone

QR code to add LINE @Bankoos

LINE ID: @Bankoos

Open LINE on this computer