Skip to content

core: decouple rbac privileges and semantics from PolarisAuthorizableOperations#4006

Merged
sungwy merged 5 commits intoapache:mainfrom
sungwy:decouple-rbac-from-ops
Mar 20, 2026
Merged

core: decouple rbac privileges and semantics from PolarisAuthorizableOperations#4006
sungwy merged 5 commits intoapache:mainfrom
sungwy:decouple-rbac-from-ops

Conversation

@sungwy
Copy link
Copy Markdown
Contributor

@sungwy sungwy commented Mar 17, 2026

Refactoring to decouple RBAC specific privilege based authorization semantics from PolarisAuthorizableOperations. The PR includes a unit test suite that verifies that all PolarisAuthorizableOperations have their corresponding RbacOperationSemantics defined with a targetPrivilege.

No behavior change is introduced in this PR.

Note: This is an off-shoot from #3999.

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

Copilot AI review requested due to automatic review settings March 17, 2026 03:06
@github-project-automation github-project-automation bot moved this to PRs In Progress in Basic Kanban Board Mar 17, 2026
@sungwy sungwy requested a review from dimas-b March 17, 2026 03:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors authorization logic to move RBAC privilege semantics out of PolarisAuthorizableOperation into a dedicated RbacOperationSemantics mapping, with tests ensuring every operation has explicit semantics defined.

Changes:

  • Introduced RbacOperationSemantics record to define RBAC privilege requirements per operation (plus rooting metadata).
  • Updated PolarisAuthorizerImpl to use RbacOperationSemantics for privilege checks instead of embedding privileges in the enum.
  • Simplified PolarisAuthorizableOperation to intent-level operations only and added unit tests validating the semantics mapping and constructor invariants.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
polaris-core/src/main/java/org/apache/polaris/core/auth/RbacOperationSemantics.java Adds centralized RBAC semantics mapping and validation for all authorizable operations.
polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizerImpl.java Switches authorization checks to read required privileges from RbacOperationSemantics.
polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizableOperation.java Removes embedded RBAC privilege definitions, leaving a pure operation enum.
polaris-core/src/test/java/org/apache/polaris/core/auth/RbacOperationSemanticsTest.java Adds tests ensuring complete semantics coverage and validates constructor behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Conflicts:
#	polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizableOperation.java
Copy link
Copy Markdown
Contributor

@flyingImer flyingImer left a comment

Choose a reason for hiding this comment

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

submit placeholder review to allow republish with improved draft

Copy link
Copy Markdown
Contributor

@flyingImer flyingImer left a comment

Choose a reason for hiding this comment

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

Summary

This review uses correctly posted body via submit API test.

@dimas-b
Copy link
Copy Markdown
Contributor

dimas-b commented Mar 18, 2026

@sungwy : it looks like we got conflicts from the PRs removing unused operation values 😅

record RbacOperationSemantics(
Set<PolarisPrivilege> targetPrivileges,
Set<PolarisPrivilege> secondaryPrivileges,
ResolvedPathRooting rooting) {
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.

How is rooting intended to be used? I do not see any readers of this value 🤔

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.

Is it used in a follow-up PR?

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.

Yes it is intended for use in #3999

Maybe it would make sense for me to remove this in the scope of this PR. And add it in #3999 instead

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.

up to you... I was just wondering about the usage pattern... I'll check the other PR.

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.

I'm still a bit fuzzy about the "prepend root container" logic, but it looks like it existed since day 1, so we're not changing it in these PRs, just making inputs nicer 👍

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.

yes, exactly - currently the logic is embedded into the Handler call sites and I think it should be defined here as an RBAC semantic instead.

dimas-b
dimas-b previously approved these changes Mar 18, 2026
@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Mar 18, 2026
# Conflicts:
#	polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizableOperation.java
@sungwy sungwy merged commit 4521081 into apache:main Mar 20, 2026
18 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Mar 20, 2026
@sungwy sungwy deleted the decouple-rbac-from-ops branch March 20, 2026 02:33
@flyrain
Copy link
Copy Markdown
Contributor

flyrain commented Mar 20, 2026

Thanks a lot for the change, @sungwy ! The PR is in the right direction. Checked with @dennishuo a bit yesterday. He is interested in taking a look. Given the impact of this refactor, can we give a bit more time for reviewers?

@dimas-b
Copy link
Copy Markdown
Contributor

dimas-b commented Mar 20, 2026

@flyrain : this PR has been merged, but follow-up comments and changes are welcome, of course... or are you proposing to revert it?

@sungwy
Copy link
Copy Markdown
Contributor Author

sungwy commented Mar 20, 2026

Hi @flyrain, thank you for the note.

As @dimas-b mentioned, I went ahead and merged this PR after the series of reviews here and on #3999. Since no use facing changes are introduced here, I felt it was reasonable to move things forward once it was approved.

That said, I’m very open to feedback. If there are concerns about the direction of the refactor, I’m happy to pause any follow-up changes while we take a closer look.

@dennishuo I would really appreciate your thoughts when you have a chance. Happy to adjust based on your feedback.

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.

6 participants