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

[Extensions] Create a way to identify if an Extension REST Handler will create a scheduled job #2623

Closed
Tracked by #2528
cwperks opened this issue Mar 31, 2023 · 4 comments
Labels
triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.

Comments

@cwperks
Copy link
Member

cwperks commented Mar 31, 2023

Some plugin actions, such as Anomaly Detector's Create Detector, create job definitions in an index owned by the plugin that Job Scheduler is aware of. The job definition contains a schedule section which specifies if the job runs on a CRON schedule or an an interval. This is how plugins make Job Scheduler aware that jobs exist and when to trigger the jobs to be run.

With extensions, the indices are still owned by the extension and the extension makes Job Scheduler aware of the index to look for new jobs. As part of handling async operations for extensions, the jobs definition also needs to store a token representative of the user who created the job so that Job Scheduler can request to issue new access tokens on behalf of the user.

These tokens are refresh_tokens and are tokens that themselves do not provide access to the cluster, however, Job Scheduler can request a new access token from the Security plugin on job invocation by utilizing this access token.

For this issue, a method needs to be devised to identify if an Extension REST Handler will create a scheduled job. For requests that create a scheduled job, a refresh_token (in addition to the access token) will be provided to the extension to store with the job definition.

@cwperks cwperks converted this from a draft issue Mar 31, 2023
@github-actions github-actions bot added the untriaged Require the attention of the repository maintainers and may need to be prioritized label Mar 31, 2023
@stephen-crawford
Copy link
Contributor

[Triage] This is part of the Extensions project.

@stephen-crawford stephen-crawford added triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable. and removed untriaged Require the attention of the repository maintainers and may need to be prioritized labels Apr 3, 2023
@davidlago
Copy link

@cwperks it seems like this might need to be closed in favor of different work, could you please update? Thanks!

@davidlago davidlago moved this from Todo to Defining in Security for Extensions May 11, 2023
@cwperks
Copy link
Member Author

cwperks commented May 11, 2023

I will update this issue to reflect updates discovered since this was created. At some point the user details need to be saved on job creation. I believe its possible to hook into here within JobScheduler: https://github.com/opensearch-project/job-scheduler/blob/main/src/main/java/org/opensearch/jobscheduler/sweeper/JobSweeper.java#L190-L209

I envision that JobScheduler will be able to get the IdentityService through dependency injection and there may be a method exposed by IdentityService to saveUserDetails when the document containing job details is indexed. On job invocation the JobScheduler would then request an access token through the IdentityService and security will lookup the user details in its index that tracks job IDs and associated users when it issues an access token.

@cwperks
Copy link
Member Author

cwperks commented May 16, 2023

Closing this issue in favor of: #2625

Yesterday I was able to confirm the behavior of job scheduler. The JobSweeper is an IndexOperatorListener which means it listens on indices that JobScheduler expected new job details to be indexed to.

JobScheduler should call on the identity system to persist user info on job details index, delete user info on job details deletion and issue an access token on behalf of the saved user info on job invocation.

@cwperks cwperks closed this as completed May 16, 2023
@github-project-automation github-project-automation bot moved this from Defining to Done in Security for Extensions May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.
Projects
Status: Done
Development

No branches or pull requests

3 participants