-
Notifications
You must be signed in to change notification settings - Fork 492
Add boolean-return authorization helper for control-flow decisions #5034
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
Open
ZephyrYWZhou
wants to merge
1
commit into
apache:main
Choose a base branch
from
ZephyrYWZhou:refactor-boolean-auth-helper
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about using
authorize()just in one narrow sub-case. This is prone to correctness deviations on different authorizer impl. call paths.I'd prefer to switch all callers from
authorizeOrThrow()toauthorize()and remove the old method.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense to me, it looks like there are 22 authorizeOrThrow call sites across CatalogHandler (9), PolicyCatalogHandler (3), and PolarisAdminService (10). I can take the full migration task there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dimas-b Quick clarification on the scope: when you say "switch all callers from
authorizeOrThrow()toauthorize()and remove the old method," do you mean removing only the legacy overloads (those takingprincipal,activatedEntities,op,target,secondary) while keepingauthorizeOrThrow(AuthorizationState, AuthorizationRequest)? Or do you mean removing allauthorizeOrThrow()variants and having every call site handleAuthorizationDecisiondirectly?My preference is to keep
authorizeOrThrow(state, request)since it's a thin convenience wrapper overauthorize().isAllowed()and most call sites simply want to throw on denial. The main benefit, in my view, is removing the legacy overloads that bypass the decision-native path.CC: @sungwy for opinion as well
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update on the broader migration - I tried switching all
authorizeOrThrowcall sites toauthorize(state, request)and ran into a fundamental issue.The legacy path operates on already-resolved entities, while
authorize(state, request)re-resolves them viagetResolvedSecurable(). Many existing call sites don't populate the resolution manifest in a way that's compatible with this re-resolution, resulting inIllegalStateException: never_registered_top_level_name_and_type_for_resolved_entity.The
loadTablechange in this PR works because its manifest is already compatible. Other call sites will require manifest changes in addition to the authorization API switch, which seems to align with the broader migration.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the
authorize()method is meant to be the main method. So the work to migrate all callers to using it needs to be done at some point.@ZephyrYWZhou : If you feel like taking that task, your efforts will be greatly appreciated. Yet, it's your choice, of course. It may be possible to make a new smaller preparatory PRs before using
authorize()at all call sites.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good @dimas-b, I would be willing and beyond thrilled to take that task. I will make smaller preparatory PRs as they will be needed before full migration. Thanks