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

[Response Ops][Task Manager][PoC] Run tasks as the current user #205577

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

JiaweiWu
Copy link
Contributor

@JiaweiWu JiaweiWu commented Jan 6, 2025

Summary

Resolves: #190661

This PR is a proof of concept allowing tasks to be ran scoped as the current user. It accomplishes this by creating an API when the user schedules this task. It will then persist the API key in the task instance which allows the task handler to have access to the user's privileges.

To test:

  1. Run yarn start --run-examples
  2. Navigate to http://localhost:5601/app/triggersActionsUiExample/task_manager_with_api_key
  3. Click on Schedule Task 1 and 2, this will schedule a mock test that is defined in x-pack/platform/plugins/shared/alerting/server/plugin.ts, which prints out the task instance and the scoped clients.
  4. Click on Remove to cancel the task, which then cleans up and invalidates the API keys.
  5. Reschedule the 2 tasks and click on Remove All Tasks which will bulk remove tasks and invalidate API keys.

Limitation of this approach:

  • Because we depend on a request, this would mean every schedule that is tied to a user needs to be triggered using a request. (Unless we have a way of generating an API key without using the request).

@JiaweiWu JiaweiWu requested a review from a team as a code owner January 6, 2025 04:55
@elasticmachine
Copy link
Contributor

elasticmachine commented Jan 6, 2025

💔 Build Failed

Failed CI Steps

History

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 this pull request may close these issues.

[Task Manager] Extend Task Manager capabilities to support the task to execute as a current user
3 participants