-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add security support for alerts and actions #41389
Conversation
Pinging @elastic/kibana-stack-services |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I could understand, LGTM
x-pack/legacy/plugins/actions/server/create_fire_function.test.ts
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/actions/server/lib/get_create_task_runner_function.ts
Outdated
Show resolved
Hide resolved
56cc5c5
to
07b923f
Compare
This comment has been minimized.
This comment has been minimized.
from #41389 (comment)
We're fine for now, but I'm going to open an issue for config-schema because there is a case that leaks data, but shouldn't affect us now. Generally config-schema only reports the type of the data (eg, "expecting a string but you passed a number"), but there's one case I've seen that does leak, and that's with But I'd like to have a safer contract (never print values, always print types) with schema.config, so will open an issue ... actually I'm going to create a backlog card because I'll have to create a test case first ... |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM.
x-pack/legacy/plugins/actions/server/lib/get_create_task_runner_function.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a bunch of comments; only critical one is the misspelled defualt
string.
x-pack/legacy/plugins/actions/server/create_execute_function.test.ts
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/actions/server/lib/get_create_task_runner_function.test.ts
Show resolved
Hide resolved
x-pack/legacy/plugins/actions/server/lib/get_create_task_runner_function.ts
Outdated
Show resolved
Hide resolved
x-pack/test/alerting_api_integration/common/lib/space_test_utils.ts
Outdated
Show resolved
Hide resolved
x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/create.ts
Show resolved
Hide resolved
x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/update.ts
Outdated
Show resolved
Hide resolved
x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/utils.ts
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
💚 Build Succeeded |
Newer changes LGTM |
* Initial work * Cleanup add createAPIKey fn pt1 * Change getServices function to take request as parameter * Use API key when executing alerts * Revert task manager using encrypted saved objects * Store fired actions within a saved object to encrypt API keys * Fix fireActionId * Cleanup code, fix type check error * Add a type for getScopedSavedObjectsClient * Fix getBasePath and spaceIdToNamespace functions * Add safety check for API key and action * Fix integration tests * Fix broken jest tests * Cleanup * Rename generatedApiKey to apiKeyValue * Ensure access to action record * Cleanup * Add unit tests * Fix variable conflict * Revert task manager specific code (no longer needed) * Remove fire terminology * Move tests to spaces and security folder * Use ES Archiver to remove spaces (empty_kibana) * Fix missing pieces * Convert action tests to run per user * Convert alerting tests to run per user * Fix type check issue * Fix failing test * Add callCluster and savedObjectsClient authorization tests * Make savedObjectsClient return 403 for authorization tests * Cleanup * Fix test failure * Common function to get data from test index * Create ObjectRemover * Cleanup * useApiKey now provided to functions instead of relying on condition of two strings * Fix typo * Make tests it(...) start with should * Rename useApiKey to isSecurityEnabled * Merge apiKeyId and apiKeyValue into one * Update docs * Use feature controls for list alert / action types API * Remove need to add ! in TypeScript for required plugins * Fix ESLint issue * Include actions and alertTypeParams into AAD and genereate new API key on update * Generate random id for API key name attribute * Include interval in AAD * Send pre-encoded string * Fix ExecutorError * Fix apiKey snapshot * Fix 'default' typo * De-compose apiKey * Refresh API key when enabling / disabling an alert * Add updatedBy * Make unauthorized APIs return 404
* Initial work * Cleanup add createAPIKey fn pt1 * Change getServices function to take request as parameter * Use API key when executing alerts * Revert task manager using encrypted saved objects * Store fired actions within a saved object to encrypt API keys * Fix fireActionId * Cleanup code, fix type check error * Add a type for getScopedSavedObjectsClient * Fix getBasePath and spaceIdToNamespace functions * Add safety check for API key and action * Fix integration tests * Fix broken jest tests * Cleanup * Rename generatedApiKey to apiKeyValue * Ensure access to action record * Cleanup * Add unit tests * Fix variable conflict * Revert task manager specific code (no longer needed) * Remove fire terminology * Move tests to spaces and security folder * Use ES Archiver to remove spaces (empty_kibana) * Fix missing pieces * Convert action tests to run per user * Convert alerting tests to run per user * Fix type check issue * Fix failing test * Add callCluster and savedObjectsClient authorization tests * Make savedObjectsClient return 403 for authorization tests * Cleanup * Fix test failure * Common function to get data from test index * Create ObjectRemover * Cleanup * useApiKey now provided to functions instead of relying on condition of two strings * Fix typo * Make tests it(...) start with should * Rename useApiKey to isSecurityEnabled * Merge apiKeyId and apiKeyValue into one * Update docs * Use feature controls for list alert / action types API * Remove need to add ! in TypeScript for required plugins * Fix ESLint issue * Include actions and alertTypeParams into AAD and genereate new API key on update * Generate random id for API key name attribute * Include interval in AAD * Send pre-encoded string * Fix ExecutorError * Fix apiKey snapshot * Fix 'default' typo * De-compose apiKey * Refresh API key when enabling / disabling an alert * Add updatedBy * Make unauthorized APIs return 404
This PR makes alerting and actions plugin work when security is enabled. It takes advantage of Elasticsearch API keys to run requests on behalf of a user at future times.
The PR also contains the following changes:
x-pack/test/ui_capabilities
style with different permutations. Right now it tests only for spaces & security enabled, future PRs will add spaces only and security only.action_task_params
before scheduling a task. This saved object encrypts the API key so it can be passed from an alert to an action. (to support executing actions on behalf of the creator of the alert).getServices
now takes a request instead of custom parameters. This facilitates passing a real request and a fake request using API keys.getCreateTaskRunnerFunction
for alerting).registerFeature
within init to allow tests to try different permutations for a user using the savedObjectsClient within an executor (create alert but can't read dashboard. This allows us to confirm the savedObjectsClient is scoped to the user).createdBy
on the alert in future scenario we want to know who's API keys are with the saved object.Fixes: #40021
Fixes: #42959