Skip to main content

License Check

The Elasticsearch license must be Elastic Basic License. Apinizer uses the simple authentication method supported by the X-Pack security plugin included in this license. To check the Elasticsearch license information, make the following request:

Enabling Security

By default, Elasticsearch security settings are not enabled. To enable the security option, add the following property to the config/elasticsearch.yml file.
If there are multiple nodes, this property must be enabled on all of them.
After this operation, the Elasticsearch application must be restarted.

Encrypting Communication Between Nodes in the Cluster (TLS Settings)

If you encounter the following error after Elasticsearch restarts, or if there are multiple nodes, the settings in this section should be configured. When security is enabled and running in a production environment, communication between Elasticsearch nodes must be encrypted. This communication occurs at the transport layer.
If there are multiple nodes, this setting must be configured on all of them.
For clusters with multiple nodes, the following settings and other optional settings should be noted in the config/elasticsearch.yml file:

Certificate Creation

1

Creating CA certificate

Use the following command to create a certificate:
This file does not need to be password-protected, but it is not recommended.
2

Creating certificate

Create a certificate using the CA certificate:
3

Moving certificates

Create the config/certs directory and move the certificates there:
Before proceeding, ensure that these certificate files have the same privileges as the Elasticsearch files.
If you get the error “could not find java in JAVA_HOME at /tools/java/home/bin/java”, use the following two commands to set the environment variables required for Java applications to run correctly.
Then, the following fields must be added to the /config/elasticsearch.yml file.
After this operation, the Elasticsearch application must be restarted.
You can check the security activation status with the following request.
Example output:
When this field is activated, any request without credentials will be rejected as follows.
Example error output:

Creating Built-in User Passwords

Elasticsearch’s default built-in username is elastic. However, there is no password created for this username.
When assigning passwords, all built-in users’ passwords will be changed.
This step is necessary to create a new user after enabling Elasticsearch security. These credentials can also be defined in Apinizer API Manager.

Adding Users

To add or update a new user, make the following request. In the request, a new user with username apinizer_es_cluster, password apinizer, and role superuser has been added.
If user information is updated, it will return as “created” : false.
Example output:

Password Reset

To change the password:
If the above command doesn’t work and the passwords of users in Elasticsearch are lost, you can recover the cluster by creating a new user from the command line. You can update the password information with the existing username using the credentials of the user you created.
Additionally;
  • When sending requests through API testing tools like Postman, Authorization: Basic <base64 encoded username:password> information must be added to the request’s header field.
  • To manage users through Kibana, go to Stack Management > Security > User from the menu. The following fields must be added to the Kibana configuration file /config/kibana.yml.
Additional commands;

Apinizer Configuration

The username and password of the defined user are configured from the Elasticsearch Clusters page in Apinizer Manager Console.
Elasticsearch Clusters - Authentication

Apinizer - Elasticsearch Clusters page - Authentication configuration

1

Enabling authentication

Enable the authentication switch button.
2

Entering credentials

Enter the username and password information.