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

ความปลอดภัยระดับฟิลด์และเอกสาร

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

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

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

Why Fine-Grained Security?

In Elasticsearch, you might not want every user to see all data. Sometimes, certain users should only access specific parts of documents or only a subset of documents.

This is where fine-grained security comes in. It allows you to control access at a much more detailed level than just index permissions.

What is Field Level Security (FLS)?

Field Level Security (FLS) lets you restrict which fields within a document a user can see. Imagine a product document with many fields.

  • A sales agent might only need to see product_name and price.
  • An inventory manager might need quantity and supplier_id.

FLS ensures users only retrieve the fields relevant to their role, hiding sensitive or irrelevant data.

Configuring FLS in Roles

FLS is configured within a user's role definition. You specify which fields are granted (allowed) or excepted (disallowed) for specific indices.

Using grant is generally safer as it follows a whitelist approach, only allowing explicitly listed fields.

{
  "applications": [],
  "cluster": [],
  "indices": [
    {
      "names": ["products"],
      "privileges": ["read"],
      "field_security": {
        "grant": ["product_name", "price"]
      }
    }
  ],
  "run_as": [],
  "metadata": {},
  "transient_metadata": {}
}

FLS Example: Product Viewer Role

Let's create a role named product_viewer. Users with this role can read documents from the products index, but only see the product_name and price fields.

Other fields like internal_cost or supplier_secret would be hidden.

PUT /_security/role/product_viewer
{
  "indices": [
    {
      "names": ["products"],
      "privileges": ["read"],
      "field_security": {
        "grant": ["product_name", "price"]
      }
    }
  ]
}

What is Document Level Security (DLS)?

Document Level Security (DLS) allows you to restrict which documents a user can see. Instead of hiding fields, DLS filters entire documents based on a query.

For example, a regional sales manager should only see sales orders from their specific region, not from other regions.

Configuring DLS in Roles

DLS is configured in a role using a query object. This query acts as a filter that is automatically applied to all search requests made by users assigned to that role.

Only documents matching this query will be returned to the user, regardless of their original search request.

{
  "applications": [],
  "cluster": [],
  "indices": [
    {
      "names": ["sales_data"],
      "privileges": ["read"],
      "query": {
        "term": { "region.keyword": "east" }
      }
    }
  ],
  "run_as": [],
  "metadata": {},
  "transient_metadata": {}
}

DLS Example: East Region Sales

Let's create a role named east_sales_manager. Users with this role can read documents from the sales_data index, but only those documents where the region field is east.

This effectively isolates sales data by region.

PUT /_security/role/east_sales_manager
{
  "indices": [
    {
      "names": ["sales_data"],
      "privileges": ["read"],
      "query": {
        "term": { "region.keyword": "east" }
      }
    }
  ]
}

Combining FLS and DLS

You can apply both Field Level Security and Document Level Security within a single role definition.

This means a user could be restricted to seeing only specific fields, AND only specific documents that match a filter query. This offers a very powerful way to create fine-grained access control.

Best Practices for FLS/DLS

When implementing FLS and DLS:

  • Design roles carefully: Plan out exactly what each user group needs to see.
  • Test thoroughly: Always verify that your roles provide the intended level of access, and nothing more.
  • Use `grant` for FLS: Whitelisting fields is generally more secure than blacklisting.
  • Keep DLS queries simple: Complex queries can impact performance.
  • Least privilege: Always grant the minimum necessary permissions.

Quick Check: Security Features

Which of the following statements about Elasticsearch Field and Document Level Security are true?

Recap: Fine-Grained Security

You've learned about Field Level Security (FLS) for restricting visible fields and Document Level Security (DLS) for filtering documents based on queries.

These powerful features, configured within user roles, enable you to create highly granular access control, ensuring users only see the data they are authorized for. This is crucial for maintaining data privacy and security in your Elasticsearch cluster.

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

บทเรียน “ความปลอดภัยระดับฟิลด์และเอกสาร” ฟรีหรือไม่

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

คุณจะเรียนรู้อะไรในบทเรียน “ความปลอดภัยระดับฟิลด์และเอกสาร”

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

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

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