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

[ResponseOps] Granular Connector RBAC - adding API key to event log #204114

Merged

Conversation

doakalexi
Copy link
Contributor

@doakalexi doakalexi commented Dec 12, 2024

Part of #180908

Summary

This change is part of adding granular RBAC for SecuritySolution connectors. In this PR, I updated the action executor to log API key details when a connector is executed by a user authenticated via API key. The public name and id of the API key are now included in the event log.

Checklist

Check the PR satisfies following conditions.

To verify

  1. Create an API key
  2. Create a connector that will successfully run, it doesn't have to be SentinelOne.
  3. Run the following with the ID and correct params for your connector type.
curl -X POST "http://localhost:5601/api/actions/connector/$CONNECTOR_ID/_execute" -H 'Authorization: ApiKey $API_KEY' -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
{
  "params": {
    "message": "hi"
  }
}'
  1. Go to dev tools and run the following query to verify that the API key information is stored in the event log
GET /.kibana-event-log*/_search
{
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "event.provider": {
              "value": "actions"
            }
          }
        }
      ]
    }
  }

@doakalexi doakalexi changed the title Adding api key to action event log [ResponseOps] Granular Connector RBAC - adding API key to event log Dec 13, 2024
@doakalexi doakalexi added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) release_note:skip Skip the PR/issue when compiling release notes v8.18.0 labels Dec 17, 2024
@doakalexi doakalexi marked this pull request as ready for review December 17, 2024 01:10
@doakalexi doakalexi requested review from a team as code owners December 17, 2024 01:10
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@doakalexi doakalexi added the backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) label Dec 17, 2024
Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

LGTM, just one question for @elastic/es-security on the stability of api_key property.

Copy link
Contributor

@js-jankisalvi js-jankisalvi left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@doakalexi doakalexi requested review from pmuellr and removed request for pmuellr December 18, 2024 15:24
Copy link
Contributor

@mikecote mikecote left a comment

Choose a reason for hiding this comment

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

Changes LGTM! Tested locally and saw the API key tracked.

@doakalexi doakalexi enabled auto-merge (squash) December 19, 2024 15:20
@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner December 19, 2024 15:42
@doakalexi doakalexi removed request for pmuellr and a team December 19, 2024 17:04
@doakalexi doakalexi merged commit 1ba2716 into elastic:main Dec 19, 2024
8 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12418639566

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/core-security-common 0 1 +1
Unknown metric groups

API count

id before after diff
@kbn/core-security-common 21 22 +1
@kbn/security-plugin-types-common 126 127 +1
security 458 461 +3
total +5

History

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 19, 2024
…lastic#204114)

Part of elastic#180908

## Summary

This change is part of adding granular RBAC for SecuritySolution
connectors. In this PR, I updated the action executor to log API key
details when a connector is executed by a user authenticated via API
key. The public name and id of the API key are now included in the event
log.

### Checklist

Check the PR satisfies following conditions.

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### To verify

1. Create an API key
2. Create a connector that will successfully run, it doesn't have to be
SentinelOne.
3. Run the following with the ID and correct params for your connector
type.
```
curl -X POST "http://localhost:5601/api/actions/connector/$CONNECTOR_ID/_execute" -H 'Authorization: ApiKey $API_KEY' -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
{
  "params": {
    "message": "hi"
  }
}'
```
4. Go to dev tools and run the following query to verify that the API
key information is stored in the event log
```
GET /.kibana-event-log*/_search
{
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "event.provider": {
              "value": "actions"
            }
          }
        }
      ]
    }
  }
```

(cherry picked from commit 1ba2716)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Dec 19, 2024
… log (#204114) (#204996)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ResponseOps] Granular Connector RBAC - adding API key to event log
(#204114)](#204114)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Alexi
Doak","email":"109488926+doakalexi@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-12-19T18:30:15Z","message":"[ResponseOps]
Granular Connector RBAC - adding API key to event log (#204114)\n\nPart
of https://github.com/elastic/kibana/issues/180908\r\n\r\n##
Summary\r\n\r\nThis change is part of adding granular RBAC for
SecuritySolution\r\nconnectors. In this PR, I updated the action
executor to log API key\r\ndetails when a connector is executed by a
user authenticated via API\r\nkey. The public name and id of the API key
are now included in the event\r\nlog.\r\n\r\n### Checklist\r\n\r\nCheck
the PR satisfies following conditions. \r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### To
verify\r\n\r\n1. Create an API key\r\n2. Create a connector that will
successfully run, it doesn't have to be\r\nSentinelOne.\r\n3. Run the
following with the ID and correct params for your
connector\r\ntype.\r\n```\r\ncurl -X POST
\"http://localhost:5601/api/actions/connector/$CONNECTOR_ID/_execute\"
-H 'Authorization: ApiKey $API_KEY' -H 'kbn-xsrf: true' -H
'Content-Type: application/json' -d'\r\n{\r\n \"params\": {\r\n
\"message\": \"hi\"\r\n }\r\n}'\r\n```\r\n4. Go to dev tools and run the
following query to verify that the API\r\nkey information is stored in
the event log\r\n```\r\nGET /.kibana-event-log*/_search\r\n{\r\n
\"sort\": [\r\n {\r\n \"@timestamp\": {\r\n \"order\": \"desc\"\r\n
}\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"filter\": [\r\n
{\r\n \"term\": {\r\n \"event.provider\": {\r\n \"value\":
\"actions\"\r\n }\r\n }\r\n }\r\n ]\r\n }\r\n
}\r\n```","sha":"1ba2716c7b00086b35788d7714781b252be1d6a0","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ResponseOps","v9.0.0","backport:prev-minor","v8.18.0"],"title":"[ResponseOps]
Granular Connector RBAC - adding API key to event
log","number":204114,"url":"https://github.com/elastic/kibana/pull/204114","mergeCommit":{"message":"[ResponseOps]
Granular Connector RBAC - adding API key to event log (#204114)\n\nPart
of https://github.com/elastic/kibana/issues/180908\r\n\r\n##
Summary\r\n\r\nThis change is part of adding granular RBAC for
SecuritySolution\r\nconnectors. In this PR, I updated the action
executor to log API key\r\ndetails when a connector is executed by a
user authenticated via API\r\nkey. The public name and id of the API key
are now included in the event\r\nlog.\r\n\r\n### Checklist\r\n\r\nCheck
the PR satisfies following conditions. \r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### To
verify\r\n\r\n1. Create an API key\r\n2. Create a connector that will
successfully run, it doesn't have to be\r\nSentinelOne.\r\n3. Run the
following with the ID and correct params for your
connector\r\ntype.\r\n```\r\ncurl -X POST
\"http://localhost:5601/api/actions/connector/$CONNECTOR_ID/_execute\"
-H 'Authorization: ApiKey $API_KEY' -H 'kbn-xsrf: true' -H
'Content-Type: application/json' -d'\r\n{\r\n \"params\": {\r\n
\"message\": \"hi\"\r\n }\r\n}'\r\n```\r\n4. Go to dev tools and run the
following query to verify that the API\r\nkey information is stored in
the event log\r\n```\r\nGET /.kibana-event-log*/_search\r\n{\r\n
\"sort\": [\r\n {\r\n \"@timestamp\": {\r\n \"order\": \"desc\"\r\n
}\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"filter\": [\r\n
{\r\n \"term\": {\r\n \"event.provider\": {\r\n \"value\":
\"actions\"\r\n }\r\n }\r\n }\r\n ]\r\n }\r\n
}\r\n```","sha":"1ba2716c7b00086b35788d7714781b252be1d6a0"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/204114","number":204114,"mergeCommit":{"message":"[ResponseOps]
Granular Connector RBAC - adding API key to event log (#204114)\n\nPart
of https://github.com/elastic/kibana/issues/180908\r\n\r\n##
Summary\r\n\r\nThis change is part of adding granular RBAC for
SecuritySolution\r\nconnectors. In this PR, I updated the action
executor to log API key\r\ndetails when a connector is executed by a
user authenticated via API\r\nkey. The public name and id of the API key
are now included in the event\r\nlog.\r\n\r\n### Checklist\r\n\r\nCheck
the PR satisfies following conditions. \r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### To
verify\r\n\r\n1. Create an API key\r\n2. Create a connector that will
successfully run, it doesn't have to be\r\nSentinelOne.\r\n3. Run the
following with the ID and correct params for your
connector\r\ntype.\r\n```\r\ncurl -X POST
\"http://localhost:5601/api/actions/connector/$CONNECTOR_ID/_execute\"
-H 'Authorization: ApiKey $API_KEY' -H 'kbn-xsrf: true' -H
'Content-Type: application/json' -d'\r\n{\r\n \"params\": {\r\n
\"message\": \"hi\"\r\n }\r\n}'\r\n```\r\n4. Go to dev tools and run the
following query to verify that the API\r\nkey information is stored in
the event log\r\n```\r\nGET /.kibana-event-log*/_search\r\n{\r\n
\"sort\": [\r\n {\r\n \"@timestamp\": {\r\n \"order\": \"desc\"\r\n
}\r\n }\r\n ],\r\n \"query\": {\r\n \"bool\": {\r\n \"filter\": [\r\n
{\r\n \"term\": {\r\n \"event.provider\": {\r\n \"value\":
\"actions\"\r\n }\r\n }\r\n }\r\n ]\r\n }\r\n
}\r\n```","sha":"1ba2716c7b00086b35788d7714781b252be1d6a0"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Alexi Doak <109488926+doakalexi@users.noreply.github.com>
stratoula pushed a commit to stratoula/kibana that referenced this pull request Jan 2, 2025
…lastic#204114)

Part of elastic#180908

## Summary

This change is part of adding granular RBAC for SecuritySolution
connectors. In this PR, I updated the action executor to log API key
details when a connector is executed by a user authenticated via API
key. The public name and id of the API key are now included in the event
log.

### Checklist

Check the PR satisfies following conditions. 

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### To verify

1. Create an API key
2. Create a connector that will successfully run, it doesn't have to be
SentinelOne.
3. Run the following with the ID and correct params for your connector
type.
```
curl -X POST "http://localhost:5601/api/actions/connector/$CONNECTOR_ID/_execute" -H 'Authorization: ApiKey $API_KEY' -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
{
  "params": {
    "message": "hi"
  }
}'
```
4. Go to dev tools and run the following query to verify that the API
key information is stored in the event log
```
GET /.kibana-event-log*/_search
{
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "event.provider": {
              "value": "actions"
            }
          }
        }
      ]
    }
  }
```
benakansara pushed a commit to benakansara/kibana that referenced this pull request Jan 2, 2025
…lastic#204114)

Part of elastic#180908

## Summary

This change is part of adding granular RBAC for SecuritySolution
connectors. In this PR, I updated the action executor to log API key
details when a connector is executed by a user authenticated via API
key. The public name and id of the API key are now included in the event
log.

### Checklist

Check the PR satisfies following conditions. 

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### To verify

1. Create an API key
2. Create a connector that will successfully run, it doesn't have to be
SentinelOne.
3. Run the following with the ID and correct params for your connector
type.
```
curl -X POST "http://localhost:5601/api/actions/connector/$CONNECTOR_ID/_execute" -H 'Authorization: ApiKey $API_KEY' -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
{
  "params": {
    "message": "hi"
  }
}'
```
4. Go to dev tools and run the following query to verify that the API
key information is stored in the event log
```
GET /.kibana-event-log*/_search
{
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "event.provider": {
              "value": "actions"
            }
          }
        }
      ]
    }
  }
```
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Jan 13, 2025
…lastic#204114)

Part of elastic#180908

## Summary

This change is part of adding granular RBAC for SecuritySolution
connectors. In this PR, I updated the action executor to log API key
details when a connector is executed by a user authenticated via API
key. The public name and id of the API key are now included in the event
log.

### Checklist

Check the PR satisfies following conditions. 

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### To verify

1. Create an API key
2. Create a connector that will successfully run, it doesn't have to be
SentinelOne.
3. Run the following with the ID and correct params for your connector
type.
```
curl -X POST "http://localhost:5601/api/actions/connector/$CONNECTOR_ID/_execute" -H 'Authorization: ApiKey $API_KEY' -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
{
  "params": {
    "message": "hi"
  }
}'
```
4. Go to dev tools and run the following query to verify that the API
key information is stored in the event log
```
GET /.kibana-event-log*/_search
{
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "event.provider": {
              "value": "actions"
            }
          }
        }
      ]
    }
  }
```
viduni94 pushed a commit to viduni94/kibana that referenced this pull request Jan 23, 2025
…lastic#204114)

Part of elastic#180908

## Summary

This change is part of adding granular RBAC for SecuritySolution
connectors. In this PR, I updated the action executor to log API key
details when a connector is executed by a user authenticated via API
key. The public name and id of the API key are now included in the event
log.

### Checklist

Check the PR satisfies following conditions. 

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### To verify

1. Create an API key
2. Create a connector that will successfully run, it doesn't have to be
SentinelOne.
3. Run the following with the ID and correct params for your connector
type.
```
curl -X POST "http://localhost:5601/api/actions/connector/$CONNECTOR_ID/_execute" -H 'Authorization: ApiKey $API_KEY' -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
{
  "params": {
    "message": "hi"
  }
}'
```
4. Go to dev tools and run the following query to verify that the API
key information is stored in the event log
```
GET /.kibana-event-log*/_search
{
  "sort": [
    {
      "@timestamp": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "event.provider": {
              "value": "actions"
            }
          }
        }
      ]
    }
  }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants