We started using xpack/shield with ElasticSearch 5.2. Unfortunately, we get random auth errors and can't even get logstash running because of it (it was running fine before).
When requesting
http://kibana:9200/_template/my-index-template with
correct auth headers via Postman, we sometimes get a successful result, the
rest of the time we get the following error. It's the exact same request both
times, once it works, once it doesn't.
{
"error": {
"root_cause": [
{
"type": "security_exception",
"reason": "error attempting to authenticate request",
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
}
],
"type": "security_exception",
"reason": "error attempting to authenticate request",
"caused_by": {
"type": "illegal_state_exception",
"reason": "authentication is already present in the context"
},
"header": {
"WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
}
},
"status": 401
}
Logs:
[2017-02-23T15:37:14,191] [transport] [access_granted] origin_type=[rest], origin_address=[10.15.66.199], principal=[logstash_internal], action=[indices:admin/template/get], request=[GetIndexTemplatesRequest]
[2017-02-23T15:37:15,365] [transport] [access_granted] origin_type=[rest], origin_address=[10.15.66.199], principal=[logstash_internal], action=[indices:admin/template/get], request=[GetIndexTemplatesRequest]
[2017-02-23T15:37:15,936] [rest] [authentication_failed] origin_address=[10.15.66.199], principal=[logstash_internal], uri=[/_template/my-index-template]
[2017-02-23T15:37:16,375] [rest] [authentication_failed] origin_address=[10.15.66.199], principal=[logstash_internal], uri=[/_template/my-index-template]
We use the "logstash_internal" user with role "logstash_writer", taken from this setup. I've temporarily given logstash_writer all privileges I could find. Given the sporadic nature of the problem, I guess that's not the cause.
_xpack/security/role/logstash_writer:
{"logstash_writer":{"cluster":["manage_index_templates","monitor","all","manage","manage_security"],"indices":[{"names":["logstash-*","otherindex1-*","thing-requests-new-*","thing-requests-*"],"privileges":["write","delete","create_index","all"],"field_security":{"grant":["*"]}}],"run_as":[],"metadata":{},"transient_metadata":{"enabled":true}}}
_xpack/security/user/logstash_internal:
{"logstash_internal":{"username":"logstash_internal","roles":["logstash_writer"],"full_name":"Internal Logstash User","email":"devnull@dev-null.at","metadata":{},"enabled":true}}
Elasticsearch config:
path.data: /var/lib/elasticsearch/data
network.host: localhost
network.bind_host: 0.0.0.0
http.port: 9200
node.max_local_storage_nodes: 1
action.destructive_requires_name: true
indices.fielddata.cache.size: 20%
xpack.security.audit.enabled: true
xpack:
security:
authc:
realms:
ldap1:
type: ldap
order: 0
url: "ldaps://XXXXXXXXXX:636"
bind_dn: "uid=kibana,ou=XXXXXXX"
bind_password: XXXXXXXXX
user_search:
base_dn: "XXXXXXX"
attribute: uid
group_search:
base_dn: "XXXXXXXXX"
files:
role_mapping: "CONFIG_DIR/x-pack/role_mapping.yml"
unmapped_groups_as_roles: true
xpack:
security:
authc:
realms:
native1:
type: native
order: 1
action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*