Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kibana API key generation for synthetic service #398

Closed
shahzad31 opened this issue Nov 22, 2021 · 0 comments · Fixed by elastic/kibana#119590
Closed

Kibana API key generation for synthetic service #398

shahzad31 opened this issue Nov 22, 2021 · 0 comments · Fixed by elastic/kibana#119590
Assignees

Comments

@shahzad31
Copy link

We need to pass an API key generated by kibana to the synthetic service, that will be used by heartbeat to communicate with elasticsearch.

We will generate an API key and save it as an encrypted saved object and will reuse it every-time we need to pass monitors configurations to the synthetics service.

Docs for encrypted saved objects https://github.com/elastic/kibana/blob/main/x-pack/plugins/encrypted_saved_objects/README.md

We will have to generate/reuse API keys everytime our schedule task will run or user performs CRUD operation from the UI, Point being everytime when we need to push configurations to the synthetics service

First we will need to check if API keys are enabled

await security?.authc.apiKeys?.areAPIKeysEnabled()

And then we will generate an API key using a method

    const apiKey = await security?.authc.apiKeys?.grantAsInternalUser(request, {
      name: 'synthetics-api-key',
      role_descriptors: {},
    });

API key permission

We will limit role_descriptors to allow it only to write hearbeat indices

      role_descriptors: {
        synthetics_writer: {
          cluster: ['monitor', 'read_ilm', 'read_pipeline'],
          index: [
            {
              names: ['synthetics-*', 'heartbeat-*'],
              privileges: ['view_index_metadata', 'create_doc'],
            },
          ],
        },
      },

Follow further docs
https://www.elastic.co/guide/en/kibana/master/api-keys.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant