-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix: Pass reasonForSelect to view identity for definer mode #26724
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
base: master
Are you sure you want to change the base?
Conversation
Summary: title Differential Revision: D88055399
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates Identity construction in definer-mode and system sessions to pass through additional fields such as empty roles, catalogs, and reasonForSelect, ensuring view and materialized view queries run under a fully populated Identity consistent with the current session/connector identity. Class diagram for Identity usage in definer and system sessionsclassDiagram
class Identity {
- String user
- Optional principal
- Map roles
- Map extraCredentials
- Map catalogProperties
- Optional tenant
- Optional reasonForSelect
- List clientTags
+ Identity(user, principal, roles, extraCredentials, catalogProperties, tenant, reasonForSelect, clientTags)
}
class Session {
- Identity identity
+ Identity getIdentity()
}
class ConnectorIdentity {
- String user
- Optional principal
- Map extraCredentials
- Optional reasonForSelect
+ String getUser()
+ Optional getPrincipal()
+ Map getExtraCredentials()
+ Optional getReasonForSelect()
}
class StatementAnalyzer {
+ Scope processMaterializedView(session, owner, accessControl)
+ RelationType analyzeView(query, name, owner, session, accessControl)
}
class MaterializedViewUtils {
+ static Session buildOwnerSession(session, owner, accessControl)
+ static Identity getOwnerIdentity(owner, session)
}
class SystemConnectorSessionUtil {
+ static Session toSession(transactionHandle, connectorSession)
}
class ViewAccessControl {
+ ViewAccessControl(accessControl)
}
Session --> Identity : has
ConnectorIdentity --> Identity : converted_to
StatementAnalyzer --> Identity : constructs_for_definer_mode
MaterializedViewUtils --> Identity : constructs_owner_identity
SystemConnectorSessionUtil --> Identity : constructs_system_identity
StatementAnalyzer --> ViewAccessControl : uses_in_definer_mode
SystemConnectorSessionUtil --> Session : builds
MaterializedViewUtils --> Session : builds_owner_session
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Description
When initialzing a view identity for definer mode permission checks, the reason for select is passed in as empty. This PR ensures that the same reason for select in the invoker's identity is used.
Motivation and Context
When checking definer mode view permissions, the reason for select is always set to empty, which means that permissions checks for table will contain a reason for select but for the same query, the permission check of the underlying base tables for a definer mode view will always be empty, leading to a mismatch in reason for select.
Impact
No impact on permissions checking behavior. The reason for select will now be made available for use in authorization checks for base tables of a definer mode view.
Test Plan
No impact, and existing tests pass.
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
Differential Revision: D88055399