Skip to content

docs: Add required privileges for using API Keys#4130

Merged
bmorelli25 merged 10 commits intoelastic:masterfrom
bmorelli25:docs-api-key-privs
Sep 9, 2020
Merged

docs: Add required privileges for using API Keys#4130
bmorelli25 merged 10 commits intoelastic:masterfrom
bmorelli25:docs-api-key-privs

Conversation

@bmorelli25
Copy link
Copy Markdown
Member

@bmorelli25 bmorelli25 commented Sep 1, 2020

Motivation/summary

  • This PR adds the required privileges for using API keys. Previously, we didn't do a good job of calling out the manage_api_cluster privilege, or of providing an example of how to set apm application privileges.

  • This PR adds an example workflow for creating an API key using the ES create API key API. The process used is these docs was originally documented here.

Server CLI tested with:

PUT _security/role/apm_api_key
{
  "cluster": [
    "manage_api_key"
  ],
  "applications": [
    {
      "application": "apm",
      "privileges": [
        "sourcemap:write",
        "event:write",
        "config_agent:read"
      ],
      "resources": [
        "*"
      ]
    }
  ]
}

./apm-server apikey create --name java-001

PUT _security/role/apm_api_key_sm
{
  "cluster": [
    "manage_api_key"
  ],
  "applications": [
    {
      "application": "apm",
      "privileges": [
        "sourcemap:write"
      ],
      "resources": [
        "*"
      ]
    }
  ]
}

./apm-server apikey create --sourcemap --name java-002

PUT _security/role/apm_api_key_ev
{
  "cluster": [
    "manage_api_key"
  ],
  "applications": [
    {
      "application": "apm",
      "privileges": [
        "event:write"
      ],
      "resources": [
        "*"
      ]
    }
  ]
}

./apm-server apikey create --ingest --name java-003

PUT _security/role/apm_api_key_cf
{
  "cluster": [
    "manage_api_key"
  ],
  "applications": [
    {
      "application": "apm",
      "privileges": [
        "config_agent:read"
      ],
      "resources": [
        "*"
      ]
    }
  ]
}

./apm-server apikey create --agent-config --name java-004

ES version tested with:

POST /_security/api_key
{
  "name": "java-002",
  "expiration": "1d", 
  "role_descriptors": { 
    "apm": {
      "applications": [
        {
          "application": "apm",
          "privileges": ["sourcemap:write", "event:write", "config_agent:read"],
          "resources": ["*"]
        }
      ]
    }
  }
}

echo -n GnrUT3QB7yZbSNxKET6d:RhHKisTmQ1aPCHC_TPwOvw | base64

apm-server apikey verify --credentials R25yVVQzUUI3eVpiU054S0VUNmQ6UmhIS2lzVG1RMWFQQ0hDX1RQd092dw==

Related issues

Closes #3566.
Closes #4135.

Additional work

After this PR is approved, a separate PR will need to be opened in the Beats repo to persist these changes: elastic/beats#20911

@ghost
Copy link
Copy Markdown

ghost commented Sep 1, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #4130 updated]

  • Start Time: 2020-09-09T02:13:45.373+0000

  • Duration: 4 min 2 sec

@bmorelli25 bmorelli25 requested review from a team and removed request for simitt September 2, 2020 17:24
Copy link
Copy Markdown
Member

@axw axw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a few minor things.

Co-authored-by: Andrew Wilkins <axwalk@gmail.com>
The key must be the base64 encoded representation of the API key's `id:name`.
By default, `enabled` is set to `false`, and API key support is disabled.

TIP: Not using Elastic APM agents?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

@bmorelli25 bmorelli25 merged commit a44ccdf into elastic:master Sep 9, 2020
@bmorelli25 bmorelli25 deleted the docs-api-key-privs branch September 9, 2020 02:28
bmorelli25 added a commit to bmorelli25/apm-server that referenced this pull request Sep 9, 2020
Co-authored-by: Andrew Wilkins <axwalk@gmail.com>
bmorelli25 added a commit to bmorelli25/apm-server that referenced this pull request Sep 9, 2020
Co-authored-by: Andrew Wilkins <axwalk@gmail.com>
bmorelli25 added a commit that referenced this pull request Sep 9, 2020
Co-authored-by: Andrew Wilkins <axwalk@gmail.com>
bmorelli25 added a commit that referenced this pull request Sep 9, 2020
Co-authored-by: Andrew Wilkins <axwalk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document how to create API Keys for Agent auth using the ES REST API [docs] Add required privileges for using API Keys

2 participants