0Pricing
Elasticsearch & Full Text Search Systems · Lektion

Benutzerauthentifizierung und Rollen

Konfigurieren Sie die Benutzerauthentifizierung, erstellen Sie Rollen und weisen Sie Berechtigungen zu, um zu steuern, wer auf Ihren Cluster zugreifen und welche Aktionen ausgeführt werden dürfen.

Benutzerauthentifizierung und Rollen ist eine kostenlose Elasticsearch & Full Text Search Systems-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Elasticsearch & Full Text Search Systems-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Elasticsearch & Full Text Search Systems-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Securing Your Search Data

Imagine your search engine holds sensitive customer data or internal documents. Without proper security, anyone could potentially access, modify, or delete it.

This lesson will show you how to protect your Elasticsearch cluster by controlling who can do what.

Elasticsearch Security Features

Elasticsearch's security features, part of what was formerly X-Pack, provide robust controls for your cluster. They include:

  • Authentication: Verifying user identities.
  • Authorization: Defining what authenticated users can do.
  • Encryption: Securing communication.

We'll focus on authentication and authorization in this lesson.

Activating Security Settings

To enable security, you need to configure your elasticsearch.yml file. This is typically done during the initial setup of your cluster.

Add the following line to enable security features in your configuration:

xpack.security.enabled: true

Built-in Administrator Users

When security is enabled, Elasticsearch creates several built-in users with predefined roles. The most important is the elastic user.

  • elastic: The superuser, with full administrative privileges. Use this for initial setup and critical operations.
  • kibana_system: Used by Kibana to connect to Elasticsearch.
  • logstash_system: Used by Logstash for monitoring.

You'll set passwords for these during the initial setup process.

Creating Your First User

Let's create a new user named dev_user. We'll use the Elasticsearch Users API, which allows you to manage users via REST calls.

This API call creates a user and sets their password. Remember to use strong, unique passwords!

PUT /_security/user/dev_user
{
  "password": "myStrongPassword123",
  "full_name": "Developer User",
  "email": "dev@example.com"
}

Defining User Permissions with Roles

In Elasticsearch, roles are central to authorization. A role is a collection of privileges that define what actions a user can perform.

  • Simplifies Management: Assign a role, not individual permissions, to users.
  • Granular Control: Roles can grant cluster-level and index-level privileges.
  • Cumulative: Users can have multiple roles, and their privileges are combined.

Common Predefined Roles

Elasticsearch comes with several useful built-in roles, providing common sets of permissions:

  • superuser: Grants all privileges across the cluster.
  • viewer: Can read data from all indices.
  • editor: Can read and write data to all indices.
  • kibana_user: Allows access to Kibana features.

These roles are great starting points, but often you'll need more specific control.

Crafting Custom Roles

Let's create a custom role called my_app_reader that can only read data from an index named my_application_data.

This role grants read and view_index_metadata privileges on a specific index. It also includes basic cluster monitoring privileges.

PUT /_security/role/my_app_reader
{
  "cluster": [
    "monitor",
    "read_ilm"
  ],
  "indices": [
    {
      "names": [ "my_application_data" ],
      "privileges": [ "read", "view_index_metadata" ]
    }
  ]
}

Assigning Roles to Users

Now that we have our dev_user and my_app_reader role, let's assign the role to the user. We'll update the dev_user to have this role.

Remember, users can be assigned multiple roles, inheriting all privileges from each one they possess.

PUT /_security/user/dev_user
{
  "password": "myStrongPassword123",
  "full_name": "Developer User",
  "email": "dev@example.com",
  "roles": [ "my_app_reader" ]
}

Understanding Roles & Privileges

Consider a user named analyst. This user has two roles assigned:

  • sales_reader: Grants read privilege on the sales_data index.
  • finance_writer: Grants read and write privileges on the finance_reports index.

Which of the following actions are permitted for the analyst user?

Recap: Secure Your Cluster

You've learned the fundamentals of Elasticsearch security!

  • We discussed why security is crucial for your data.
  • Explored how to enable security and identify built-in users.
  • Understood roles as collections of privileges.
  • Created custom users and roles using the Security API.
  • Assigned roles to users to control access.

Proper authentication and authorization are key to a secure and robust Elasticsearch deployment.

Häufig gestellte Fragen

Ist die Lektion „Benutzerauthentifizierung und Rollen“ kostenlos?

Ja — der vollständige Text von „Benutzerauthentifizierung und Rollen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Elasticsearch & Full Text Search Systems-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Elasticsearch & Full Text Search Systems-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Benutzerauthentifizierung und Rollen“?

Konfigurieren Sie die Benutzerauthentifizierung, erstellen Sie Rollen und weisen Sie Berechtigungen zu, um zu steuern, wer auf Ihren Cluster zugreifen und welche Aktionen ausgeführt werden dürfen. Du übst Elasticsearch & Full Text Search Systems mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Elasticsearch & Full Text Search Systems zu starten?

Keine Vorkenntnisse erforderlich. Elasticsearch & Full Text Search Systems auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.

Wie lange dauert die Lektion „Benutzerauthentifizierung und Rollen“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Elasticsearch & Full Text Search Systems-Lektion Code schreiben und ausführen?

Ja. Jede Elasticsearch & Full Text Search Systems-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Benutzerauthentifizierung und Rollen
  2. Sicherheit auf Feld- und Dokumentebene
  3. TLS/SSL und Netzwerksicherheit
  4. API-Schlüssel und Audit-Logging
← Zurück zu Elasticsearch & Full Text Search Systems