-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Verify authorization access for SET AUTHORIZATION statements #16691
Verify authorization access for SET AUTHORIZATION statements #16691
Conversation
c4bb91a
to
173f26e
Compare
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.
There are two concerns here:
-
Whether impersonation is the right precondition for this
- We discussed this when we worked on this last time, and this was one of the suggestions. I think it makes sense, but I'm no strongly sold on it yet.
-
This requires all access control to implement this in a correct way, which is error prone.
- I would suggest moving the logic to
AccessControlManager
and remove thecheckCanSetViewAuthorization
from the access control interface(s).
- I would suggest moving the logic to
Bonus concern:
- The commit message seems malformed :) It should explain why impersonation is the correct thing to do, not just that it's delegated to the access control.
core/trino-main/src/main/java/io/trino/execution/SetViewAuthorizationTask.java
Outdated
Show resolved
Hide resolved
core/trino-main/src/test/java/io/trino/security/TestFileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
...trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/FileBasedAccessControl.java
Outdated
Show resolved
Hide resolved
173f26e
to
f4d4e3a
Compare
AC, PTAL |
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.
So file-based access controls will have their own model for this? We were discussing things like checking for impersonation, does that mean this is not viable here or just undesirable?
lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/AuthorizationRule.java
Outdated
Show resolved
Hide resolved
lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/AuthorizationRule.java
Outdated
Show resolved
Hide resolved
...trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/FileBasedAccessControl.java
Outdated
Show resolved
Hide resolved
...plugin-toolkit/src/main/java/io/trino/plugin/base/security/FileBasedSystemAccessControl.java
Outdated
Show resolved
Hide resolved
@@ -83,6 +86,11 @@ public Optional<List<SystemInformationRule>> getSystemInformationRules() | |||
return systemInformationRules; | |||
} | |||
|
|||
public List<AuthorizationRule> getAuthorizationRules() |
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.
Why not return Optional
like from all the others?
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.
Because this one if it is not present is denied by default.
...oolkit/src/test/java/io/trino/plugin/base/security/BaseFileBasedSystemAccessControlTest.java
Show resolved
Hide resolved
if (!isTableOwner(context, viewName)) { | ||
denySetViewAuthorization(viewName.toString(), principal); | ||
} | ||
denySetViewAuthorization(viewName.toString(), principal); |
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.
Does this warrant a separate commit?
@Test | ||
public void testSchemaAuthorization() | ||
{ | ||
ConnectorAccessControl accessControl = createAccessControl("authorization-no-roles.json"); |
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.
Why no roles in connector access control tests?
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.
there is also authorization.json
, however file based connector access control does not support roles.
checkArgument(!rules.hasRoleRules(), "File connector access control does not support role rules");
...kit/src/test/java/io/trino/plugin/base/security/BaseFileBasedConnectorAccessControlTest.java
Outdated
Show resolved
Hide resolved
...kit/src/test/java/io/trino/plugin/base/security/BaseFileBasedConnectorAccessControlTest.java
Outdated
Show resolved
Hide resolved
AC, PTAL |
f4d4e3a
to
f71b287
Compare
@@ -678,7 +678,51 @@ as ``[email protected]``, you can use the following rules. | |||
] | |||
} | |||
|
|||
<<<<<<< HEAD |
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.
Unresolved merge conflict?
f71b287
to
94acb6e
Compare
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.
The message on the second commit should be rewritten as the new solution is to add a file based access control rule for set authorization checks. Also, I think the PR message and release notes will need a rewrite.
core/trino-main/src/main/java/io/trino/execution/SetViewAuthorizationTask.java
Show resolved
Hide resolved
...trino-plugin-toolkit/src/main/java/io/trino/plugin/base/security/FileBasedAccessControl.java
Show resolved
Hide resolved
8edefc5
to
8083741
Compare
ae08d58
to
bcd8574
Compare
bcd8574
to
1c98782
Compare
Using new rules will allow to control who can grant AUTHORIZATION (move ownership) to whom. In order to perform the SET AUTHORIZATION statement one has also ownership access to referred entity. So to be authorized to perform: ALTER TABLE T SET AUTHORIZATION USER U; one has to have access to modify the table T and proper authorization rule to move ownership to user U:
This property is no longer needed. It is required that plugin that implements access control make sure that control for SET AUTHORIZATION is implemented securely.
1c98782
to
c04f7c2
Compare
With this pull request we are going to assume from all pluggable access control to make sure that SET AUTHORIZATION statements are secure to be performed. Previously it was not clear if it is engine or access control responsibility. Hence we had
legacy.allow-set-view-authorization
config property.To accomplish that now:
hive.security=sql-standard
requires admin role privilege to performALTER ... SET AUTHORIZATION...
statementsThanks to the above
legacy.allow-set-view-authorization
can be removed.Release notes:
Hive
securty requires admin role privilege to perform
ALTER ... SET AUTHORIZATION...` statementsSecurity:
ALTER ... SET AUTHORIZATION...
to whom authorization can be set.legacy.allow-set-view-authorization
configuration property