# Enabled xpack.security.authc.api\_key.enabled=true but \_security/api\_key still not working

**URL:** https://discuss.elastic.co/t/enabled-xpack-security-authc-api-key-enabled-true-but-security-api-key-still-not-working/266831
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [March 10, 2021, 3:24pm UTC](https://discuss.elastic.co/t/enabled-xpack-security-authc-api-key-enabled-true-but-security-api-key-still-not-working/266831 "2021-03-10T15:24:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![PaulMess](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulmess/32/65628_2.png) [@PaulMess](https://discuss.elastic.co/u/PaulMess)
#### Post date: [March 10, 2021, 3:24pm UTC](https://discuss.elastic.co/t/enabled-xpack-security-authc-api-key-enabled-true-but-security-api-key-still-not-working/266831/1 "2021-03-10T15:24:42Z")

</div>

Hello, I stared a ES Cluster with xpack.security.authc.api\_key.enabled=true, If I check node settings inform that is enabled

```auto
    "security" : {
                "authc" : {
                  "api_key" : {
                    "enabled" : "true"
                  }
                },

```

But, I I try to get or create an API key, with:

```auto
POST /_security/api_key
{
  "name": "my-api-key",
  "expiration": "1d", 
  "role_descriptors": { 
    "role-a": {
      "cluster": ["all"],
      "index": [
        {
          "names": ["replica*"],
          "privileges": ["read"]
        }
      ]
    }
  }
}

```

I got

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "invalid_index_name_exception",
        "reason" : "Invalid index name [_security], must not start with '_', '-', or '+'",
        "index_uuid" : "_na_",
        "index" : "_security"
      }
    ],
    "type" : "invalid_index_name_exception",
    "reason" : "Invalid index name [_security], must not start with '_', '-', or '+'",
    "index_uuid" : "_na_",
    "index" : "_security"
  },
  "status" : 400
}

```

Should I do something else?

---

<div class="post-metadata">

### Author: ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)
#### Post date: [March 10, 2021, 3:30pm UTC](https://discuss.elastic.co/t/enabled-xpack-security-authc-api-key-enabled-true-but-security-api-key-still-not-working/266831/2 "2021-03-10T15:30:32Z")

</div>

The solution is right there in the error message you get

> "Incorrect HTTP method.. [GET], allowed: [POST]"

You need to make an HTTP POST request and you are making an HTTP GET instead. The [docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html) might also be helpful to you

---

<div class="post-metadata">

### Author: ![PaulMess](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulmess/32/65628_2.png) [@PaulMess](https://discuss.elastic.co/u/PaulMess)
#### Post date: [March 10, 2021, 3:35pm UTC](https://discuss.elastic.co/t/enabled-xpack-security-authc-api-key-enabled-true-but-security-api-key-still-not-working/266831/3 "2021-03-10T15:35:40Z")

</div>

Thanks @ikakavas I just fixed the info

---

<div class="post-metadata">

### Author: ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)
#### Post date: [March 10, 2021, 6:16pm UTC](https://discuss.elastic.co/t/enabled-xpack-security-authc-api-key-enabled-true-but-security-api-key-still-not-working/266831/4 "2021-03-10T18:16:14Z")

</div>

What version of the stack are you using and what other configuration parameters do you pass ( to I presume your docker run command ) ?

You'd need at least also `xpack.security.enabled=true`

---

<div class="post-metadata">

### Author: ![PaulMess](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulmess/32/65628_2.png) [@PaulMess](https://discuss.elastic.co/u/PaulMess)
#### Post date: [March 11, 2021, 12:14pm UTC](https://discuss.elastic.co/t/enabled-xpack-security-authc-api-key-enabled-true-but-security-api-key-still-not-working/266831/5 "2021-03-11T12:14:29Z")

</div>

I am using 7.11.0, in three boxes I am running a composer like this:

```auto
version: "3"
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.11.0
    container_name: es01
    hostname: es01
    environment:
      - node.name=es01
      - node.master=true
      - node.data=true
      - network.publish_host=172.28.198.53
      - network.host=_local_,_site_
      - transport.port=9300
      - transport.tcp.keep_alive=true
      - cluster.name=es-cluster
      - cluster.initial_master_nodes=es01,es02,es03,es04
      - discovery.seed_hosts=127.0.0.1,172.28.198.54,172.28.198.56,172.28.198.57
      - discovery.zen.minimum_master_nodes=2
      - xpack.monitoring.collection.enabled=true
      - xpack.security.enabled=true
      - xpack.security.transport.ssl.enabled=false
      - xpack.security.authc.api_key.enabled=true
      - cluster.routing.allocation.enable=all
      - path.repo=/nfs/ELK/backups
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - node.attr.size=medium
      - ELASTIC_PASSWORD=changeme
    ports:
      - "9200:9200"
      - "9300:9300"
    volumes:
      - "/var/log/elasticsearch-data/data:/usr/share/elasticsearch/data"
      - "/var/log/elasticsearch-data/config:/usr/share/elasticsearch/config"
      - "/var/log/elasticsearch-data/logs:/usr/share/elasticsearch/logs"
      - "/var/log/elasticsearch-data/plugins:/usr/share/elasticsearch/plugins"
      - "/nfs/ELK/backups:/nfs/ELK/backups"
    expose:
      - "9200"
      - "9300"
    network_mode: bridge

```

I have xpack.security.enabled=true already, just I did configure ssl yet

---

<div class="post-metadata">

### Author: ![PaulMess](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulmess/32/65628_2.png) [@PaulMess](https://discuss.elastic.co/u/PaulMess)
#### Post date: [March 11, 2021, 12:30pm UTC](https://discuss.elastic.co/t/enabled-xpack-security-authc-api-key-enabled-true-but-security-api-key-still-not-working/266831/6 "2021-03-11T12:30:52Z")

</div>

In a weird mode, If I check the settings of the node with:

```auto
curl -s -XGET "http://172.28.198.53:9200/_nodes/settings" | jq ".nodes | .[] | .settings | .xpack" > t.json

```

Appears the auth.api\_key and transport.ssl as I configured, but not the security.enabled=true

```auto
{
  "monitoring": {
    "collection": {
      "enabled": "true"
    }
  },
  "security": {
    "authc": {
      "api_key": {
        "enabled": "true"
      }
    },
    "enabled": "false",
    "transport": {
      "ssl": {
        "enabled": "false"
      }
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 8, 2021, 12:31pm UTC](https://discuss.elastic.co/t/enabled-xpack-security-authc-api-key-enabled-true-but-security-api-key-still-not-working/266831/7 "2021-04-08T12:31:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
