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

Map extension routes to permission-able action names #2589

Closed
Tracked by #2590
cwperks opened this issue Mar 27, 2023 · 2 comments
Closed
Tracked by #2590

Map extension routes to permission-able action names #2589

cwperks opened this issue Mar 27, 2023 · 2 comments
Assignees
Labels
triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.

Comments

@cwperks
Copy link
Member

cwperks commented Mar 27, 2023

Actions in OpenSearch are given names (indices:data/read/search for SearchAction for example) that directly translate into permissions in roles of the security plugin. Like native actions, plugins extend OpenSearch behavior and can register new actions to be executed on OpenSearch nodes. These actions are also given names (cluster:admin/opendistro/ad/detectors/get for GetAnomalyDetectorAction for example) and can also be granted to users via roles. In the current model of the security plugin, most actions for plugins will be granted in the cluster_permissions section of the roles of the security plugin which simply means that the action does not require any resource names like index patterns to permit the action - to differentiate cluster_permissions from index_permissions which do require a list of index patterns.

For extensions, I think ideally we will want a new section of the roles explicitly for extension_permissions to remove these actions from the cluster_permissions and index_permissions sections of the role.

A good reference for this issue is the HelloWorld example extension. See the OpenAPI spec file for the HelloWorld extension. Every route in this specification should be permissible via a short-name that can be added to a role definition in the Security plugin.

In the plugin world, the name of the permission is derived directly from the action. Take Get Detector from Anomaly Detection (AD):

GetAnomalyDetectorAction -> cluster:admin/opendistro/ad/detectors/get

When AD is converted to an extension there needs to be an equivalent:

# This is for example purposes and does not reflect current endpoints

GET /_extensions/ad/detectors/get/{id} -> extensions:ad/detector/get

Broadly speaking there are 2 types of actions in OpenSearch:

  1. Rest actions - actions that can be entirely performed on the receiving node
  2. Transport actions - actions that require coordination amongst nodes in the cluster

The security plugin currently performs auth in the Transport-layer requiring plugin developers to implement both types of actions to invoke authz checks on the request.

For extensions, authz will be performed at the REST layer and cannot rely on the action name for TransportActions. (Actions are registered in setupActions of ActionModule of core)

REST Actions also have names, a straightforward option for permissions for REST actions would be to use the REST action name.

@cwperks cwperks converted this from a draft issue Mar 27, 2023
@github-actions github-actions bot added the untriaged Require the attention of the repository maintainers and may need to be prioritized label Mar 27, 2023
@cwperks cwperks changed the title Convention for defining and permissioning extension actions Map extension routes to permission-able action names Mar 27, 2023
@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 Mar 27, 2023
@cwperks cwperks self-assigned this Mar 28, 2023
@cwperks
Copy link
Member Author

cwperks commented Mar 31, 2023

A series of draft PRs across Security, Core and SDK repos shows how this could be implemented: #2601

@davidlago davidlago moved this to In Progress in Security for Extensions May 10, 2023
@davidlago davidlago assigned DarshitChanpura and unassigned cwperks May 10, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Security for Extensions Jul 13, 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