Authentication helps check who you are before you can use a system. It keeps data safe by allowing only the right people to access it.
0
0
Authentication basics in Elasticsearch
Introduction
When you want to protect your Elasticsearch data from strangers.
When you need to make sure only certain users can add or change data.
When you want to track who is using your Elasticsearch service.
When you connect your app to Elasticsearch and want to keep it secure.
Syntax
Elasticsearch
curl -u username:password -X GET "http://localhost:9200/_security/_authenticate"This example uses basic authentication with username and password.
The -u option sends your login details securely.
Examples
Check who you are logged in as using the default 'elastic' user.
Elasticsearch
curl -u elastic:changeme -X GET "http://localhost:9200/_security/_authenticate"Use an API key for authentication instead of username and password.
Elasticsearch
curl -H "Authorization: ApiKey BASE64_ENCODED_KEY" -X GET "http://localhost:9200/_security/_authenticate"
Use a Bearer token for OAuth-style authentication.
Elasticsearch
curl -X GET "http://localhost:9200/_security/_authenticate" -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
Sample Program
This command asks Elasticsearch who you are by sending your username and password. It returns your user details if the login is correct.
Elasticsearch
curl -u elastic:changeme -X GET "http://localhost:9200/_security/_authenticate"OutputSuccess
Important Notes
Always keep your passwords and API keys secret and never share them.
Use HTTPS to keep your login details safe when sending over the internet.
Elasticsearch supports many authentication methods like basic auth, API keys, and tokens.
Summary
Authentication checks who you are before allowing access.
Elasticsearch supports basic auth, API keys, and tokens for authentication.
Use the _security/_authenticate API to verify your identity.