0Pricing
Elasticsearch & Full Text Search Systems · บทเรียน

คีย์เอพีไอและบันทึกการตรวจสอบ

รักษาความปลอดภัยการเข้าถึงจากโปรแกรมด้วยคีย์เอพีไอที่จำกัดขอบเขตแทนรหัสผ่าน และตรวจสอบได้ว่าใครทำอะไรด้วยการเปิดใช้และอ่านบันทึกการตรวจสอบของ Elasticsearch

คีย์เอพีไอและบันทึกการตรวจสอบ เป็นบทเรียน Elasticsearch & Full Text Search Systems ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Elasticsearch & Full Text Search Systems และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Elasticsearch & Full Text Search Systems มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Beyond Passwords

Applications should not authenticate with a human's username and password. Elasticsearch provides API keys: scoped, revocable credentials ideal for services. Pair them with audit logging to track every security-relevant action.

What Is an API Key

An API key is a credential tied to a set of permissions, with an optional expiration. It can be limited to a subset of the creating user's privileges, following the principle of least privilege.

Creating a Key

Use the create API key endpoint. The response includes an id and api_key value shown only once, so store it securely.

POST /_security/api_key
{
  "name": "logging-app",
  "expiration": "30d"
}

Restricting a Key

Attach role_descriptors to limit what the key can do, even if the creating user has more power. Here the key may only read one index.

POST /_security/api_key
{
  "name": "reader",
  "role_descriptors": {
    "ro": {
      "indices": [{ "names": ["logs-*"], "privileges": ["read"] }]
    }
  }
}

Using a Key

Send the base64-encoded id:api_key pair in the Authorization header with the ApiKey scheme.

GET /logs-2024/_search
Authorization: ApiKey VnVhQ2ZHY0JDZGJrU...

Revoking Keys

Compromised or retired keys are invalidated immediately, without changing any user's password. You can revoke by id, by name, or all keys owned by a user.

DELETE /_security/api_key
{
  "name": "logging-app"
}

Why Audit Logging

Audit logs answer the compliance question: who did what, when, and from where. They record authentication attempts, access grants and denials, and configuration changes.

Enabling the Audit Log

Audit logging is turned on in elasticsearch.yml. It is disabled by default because it generates significant volume.

xpack.security.audit.enabled: true

Filtering Events

Tune which events are captured with include/exclude lists to avoid drowning in noise. Common choices keep access_denied and authentication_failed while dropping routine reads.

xpack.security.audit.logfile.events.exclude: [ access_granted ]

Reading Audit Output

Audit events are written as structured JSON to a dedicated log file. Each line includes the event type, user, client IP, request path, and outcome, making it easy to ship into Kibana for analysis.

Best Practices

Rotate API keys regularly, scope them tightly, store the audit log on durable storage separate from the cluster, and alert on repeated authentication_failed events that may signal an attack.

Quick Check

Test your understanding of API keys.

Recap

You learned to secure access and accountability:

  • API keys are scoped, expiring, revocable credentials for applications.
  • Use role_descriptors to enforce least privilege.
  • Audit logging records who did what, when, and from where.
  • Filter audit events to manage volume and alert on failed authentications.

คำถามที่พบบ่อย

บทเรียน “คีย์เอพีไอและบันทึกการตรวจสอบ” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “คีย์เอพีไอและบันทึกการตรวจสอบ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Elasticsearch & Full Text Search Systems ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Elasticsearch & Full Text Search Systems มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “คีย์เอพีไอและบันทึกการตรวจสอบ”

รักษาความปลอดภัยการเข้าถึงจากโปรแกรมด้วยคีย์เอพีไอที่จำกัดขอบเขตแทนรหัสผ่าน และตรวจสอบได้ว่าใครทำอะไรด้วยการเปิดใช้และอ่านบันทึกการตรวจสอบของ Elasticsearch คุณปฏิบัติ Elasticsearch & Full Text Search Systems ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Elasticsearch & Full Text Search Systems หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Elasticsearch & Full Text Search Systems บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “คีย์เอพีไอและบันทึกการตรวจสอบ” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Elasticsearch & Full Text Search Systems นี้ได้ไหม

ได้ บทเรียน Elasticsearch & Full Text Search Systems ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การยืนยันตัวตนผู้ใช้และบทบาท
  2. ความปลอดภัยระดับฟิลด์และเอกสาร
  3. TLS/SSL และความปลอดภัยเครือข่าย
  4. คีย์เอพีไอและบันทึกการตรวจสอบ
← กลับไปที่ Elasticsearch & Full Text Search Systems