Skip to content

fix: Change auth from WRITE to READ for specGetAll#19272

Merged
aho135 merged 3 commits intoapache:masterfrom
aho135:supervisor_auth_fix
Apr 21, 2026
Merged

fix: Change auth from WRITE to READ for specGetAll#19272
aho135 merged 3 commits intoapache:masterfrom
aho135:supervisor_auth_fix

Conversation

@aho135
Copy link
Copy Markdown
Contributor

@aho135 aho135 commented Apr 7, 2026

Description

The current implementation of specGetAll is unnecessarily restrictive as it uses DATASOURCE_WRITE_RA_GENERATOR for authorization. This PR changes the Authorization to only require READ. This issue was surfaced after testing out the endpoint with the Read Only Authorizer enabled. Since the history endpoint already returns the list of all Supervisors with Read access this change makes the authorization consistent across the two endpoints

Fixed the bug ...

specGetAll returns an empty list for Supervisors when read only authorization is enabled

Release note


Key changed/added classes in this PR
  • SupervisorResource
  • SupervisorResourceTest

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.

@gianm
Copy link
Copy Markdown
Contributor

gianm commented Apr 8, 2026

I've often believed that WRITE is appropriate for permissions like this, on the rationale that the ingestion APIs should only be accessible to people with ability to manipulate ingestion objects, which of course requires WRITE permission. I guess your mental model is different, one where READ permission means the user can see ingestion objects but not necessary manipulate them. I wish that the permission model was more fine grained so we could separate READ of the data from READ of the ingestion objects.

I wonder, what's the current state of things? What authorization do other read-only APIs in /druid/indexer/v1/... require? What do the system tables sys.tasks and sys.supervisors check?

@aho135
Copy link
Copy Markdown
Contributor Author

aho135 commented Apr 8, 2026

I've often believed that WRITE is appropriate for permissions like this, on the rationale that the ingestion APIs should only be accessible to people with ability to manipulate ingestion objects, which of course requires WRITE permission. I guess your mental model is different, one where READ permission means the user can see ingestion objects but not necessary manipulate them. I wish that the permission model was more fine grained so we could separate READ of the data from READ of the ingestion objects.

I wonder, what's the current state of things? What authorization do other read-only APIs in /druid/indexer/v1/... require? What do the system tables sys.tasks and sys.supervisors check?

Thanks for the review @gianm!

I wish that the permission model was more fine grained so we could separate READ of the data from READ of the ingestion objects.

I believe @clintropolis was working on something similar to this with the addition of a Policy in the Authorizer to allow more granular control over table reads

I wonder, what's the current state of things? What authorization do other read-only APIs in /druid/indexer/v1/... require?

These API's also follow the model where users can READ all ingestion objects, but manipulation still requires WRITE. For example, task submission requires write, but /task/{taskid}/status only requires READ. Even for system tables those only require READ access, so I think the changes in this PR at least make things consistent with the current state of things

@aho135
Copy link
Copy Markdown
Contributor Author

aho135 commented Apr 14, 2026

@gianm Please let me know your thoughts on this one when you get the chance. Thanks!

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.

These API's also follow the model where users can READ all ingestion objects, but manipulation still requires WRITE. For example, task submission requires write, but /task/{taskid}/status only requires READ. Even for system tables those only require READ access, so I think the changes in this PR at least make things consistent with the current state of things

This seems reasonable to me as the updated access model is internally consistent with the other existing GET APIs noted

Comment on lines +205 to +207
Optional<SupervisorSpec> supervisorSpecOptional = manager.getSupervisorSpec(supervisorId);
return supervisorSpecOptional
.transform(spec -> SPEC_DATASOURCE_READ_RA_GENERATOR.apply(new VersionedSupervisorSpec(spec, null)))
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.

Just confirming that applying a transform directly on the optional supervisorSpecOptional won’t cause any issues without checking .isPresent(). It seems like it won’t, but I noticed this differs from the logic in filterAuthorizedSupervisorIds()

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.

What do you think about adding a function like filterAuthorizedSupervisorIdsForRead() to make read access explicit? So any new read-only APIs know to call this function instead of filterAuthorizedSupervisorIds()

Copy link
Copy Markdown
Contributor Author

@aho135 aho135 Apr 21, 2026

Choose a reason for hiding this comment

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

Thanks for the review @abhishekrb19! Yeah that was kind of a roundabout way of doing things. I made an update to filterAuthorizedSupervisorIds to pass in the Authorization function and it looks cleaner now. Lmk what you think!

@abhishekrb19
Copy link
Copy Markdown
Contributor

Thanks @aho135. Since #19243 is being included in 37.0.0, should we backport this fix to 37.0.0 as well?
cc: @cecemei

@aho135
Copy link
Copy Markdown
Contributor Author

aho135 commented Apr 21, 2026

Good call @abhishekrb19 Created #19362 for backporting!

@cecemei
Copy link
Copy Markdown
Contributor

cecemei commented Apr 21, 2026

Thanks @aho135. Since #19243 is being included in 37.0.0, should we backport this fix to 37.0.0 as well? cc: @cecemei

The underlying issue seems to exist for a while, but only just surfaced with ‎ReadOnlyAuthorizer? I’m not entirely sure a backport is necessary here.

@aho135
Copy link
Copy Markdown
Contributor Author

aho135 commented Apr 21, 2026

@cecemei Yeah this issue only surfaces with ReadOnlyAuthorizer, or any custom Authorizer which does not grant WRITE access. It's a minor bug fix, so it need not disrupt the release flow

@aho135 aho135 merged commit c217127 into apache:master Apr 21, 2026
97 of 98 checks passed
@github-actions github-actions Bot added this to the 38.0.0 milestone Apr 21, 2026
@abhishekrb19 abhishekrb19 mentioned this pull request Apr 22, 2026
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants