Skip to content

Input source security feature should work for MSQ tasks#14056

Merged
zachjsh merged 2 commits intoapache:masterfrom
zachjsh:msq-tasks-input-source-security
Apr 11, 2023
Merged

Input source security feature should work for MSQ tasks#14056
zachjsh merged 2 commits intoapache:masterfrom
zachjsh:msq-tasks-input-source-security

Conversation

@zachjsh
Copy link
Copy Markdown
Contributor

@zachjsh zachjsh commented Apr 10, 2023

Description

Previously msq controller and worker tasks did not have implementations for the getInputSourceResources() method. This causes the submission of these tasks to fail if the following auth config is enabled:

druid.auth.enableInputSourceSecurity=true

Added implementations of this method for these tasks that return an empty set of input sources. This means that for these task types, if druid.auth.enableInputSourceSecurity=true config is used, the input source types will be properly computed and authorized in the SQL layer, but not if the equivalent controller / worker tasks are submitted to the task endpoint.

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

Previously msq controller and worker tasks did not have implementations
for the `getInputSourceResources()` method. This causes the submission
of these tasks to fail if the following auth config is enabled:

`druid.auth.enableInputSourceSecurity=true`

Added implementations of for these tasks that return an empty set
of input sources. This means that for these task types, if
`druid.auth.enableInputSourceSecurity=true` config is used, the input
source types will be properly computed and authorized in the SQL
layer, but not if the equivalent controller / worker tasks are submitted
to the task endpoint.
@zachjsh zachjsh marked this pull request as ready for review April 10, 2023 20:08
@Override
public Set<ResourceAction> getInputSourceResources()
{
// the input sources are properly computed in the SQL / calcite layer, but not in the native MSQ task here.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, thinking about it, should we remove the default implementation that throws an exception in the Task interface? Making the method abstract would force developers to think about the input security model for our different task types from the ground up instead of fixing things because of an unsupported exception at runtime when the feature is enabled. Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This only throws an exception by default if a the task is used with the inputSourceType security feature enabled. I think better to default fail than to allow the the usage of the input source unsecured by default. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying! One more reason why we cannot remove the default implementation is it's a method on a common interface and can break compilation because things can be loaded from custom extensions. So I think having the default behavior is good 👍

@zachjsh zachjsh requested a review from abhishekrb19 April 11, 2023 05:56
Copy link
Copy Markdown
Contributor

@abhishekrb19 abhishekrb19 left a comment

Choose a reason for hiding this comment

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

LGTM 🦧

@zachjsh zachjsh merged commit 89bdbdc into apache:master Apr 11, 2023
@zachjsh zachjsh deleted the msq-tasks-input-source-security branch April 11, 2023 15:36
@abhishekrb19
Copy link
Copy Markdown
Contributor

abhishekrb19 commented Apr 11, 2023

Should we backport this change and #14050 to the 26.0 release? The other input source security changes are in the 26.0 release branch

zachjsh added a commit to zachjsh/druid that referenced this pull request Apr 11, 2023
### Description

Previously msq controller and worker tasks did not have implementations for the `getInputSourceResources()` method. This causes the submission of these tasks to fail if the following auth config is enabled:

`druid.auth.enableInputSourceSecurity=true`

Added implementations of this method for these tasks that return an empty set of input sources. This means that for these task types, if `druid.auth.enableInputSourceSecurity=true` config is used, the input source types will be properly computed and authorized in the SQL layer, but not if the equivalent controller / worker tasks are submitted to the task endpoint.
@clintropolis clintropolis added this to the 26.0 milestone Apr 13, 2023
clintropolis pushed a commit that referenced this pull request Apr 13, 2023
* Input source security sql layer can handle input source with multiple types (#14050)

### Description

This change allows for input sources used during MSQ ingestion to be authorized for multiple input source types, instead of just 1. Such an input source that allows for multiple types is the CombiningInputSource.

Also fixed bug that caused some input source specific functions to be authorized against the permissions

`
[
    new ResourceAction(new Resource(ResourceType.EXTERNAL, ResourceType.EXTERNAL), Action.READ),
    new ResourceAction(new Resource(ResourceType.EXTERNAL, {input_source_type}), Action.READ)
]
`

when the inputSource based authorization feature is enabled, when it should instead be authorized against

`
[
    new ResourceAction(new Resource(ResourceType.EXTERNAL, {input_source_type}), Action.READ)
]
`

* Input source security feature should work for MSQ tasks (#14056)

### Description

Previously msq controller and worker tasks did not have implementations for the `getInputSourceResources()` method. This causes the submission of these tasks to fail if the following auth config is enabled:

`druid.auth.enableInputSourceSecurity=true`

Added implementations of this method for these tasks that return an empty set of input sources. This means that for these task types, if `druid.auth.enableInputSourceSecurity=true` config is used, the input source types will be properly computed and authorized in the SQL layer, but not if the equivalent controller / worker tasks are submitted to the task endpoint.
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.

3 participants