Support Hive metastore impersonation#1441
Conversation
a937203 to
1299349
Compare
...c/main/java/io/prestosql/plugin/hive/authentication/KerberosHiveMetastoreAuthentication.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveConfig.java
Outdated
Show resolved
Hide resolved
|
Would it be sufficient to call |
1299349 to
72a6bdc
Compare
|
Thank you for the advise. I think it's sufficient too and replaced the delegation token logic with |
75aa6e9 to
d6623de
Compare
|
Hi, impersonation support is missed out for get table operation. is there any plan to add support for that as well? |
|
@AnupGS What is the use case for impersonation for read calls? We could certainly add those, but I'm not aware of any reason to do so. When using SQL standard authorization, Presto performs all the security checks using the security information provided by the metastore. |
|
@electrum this is required because HMS may impose additional checks on get_table call. @ebyhr @electrum I will share with you exact impersonation rules we have implemented. @ebyhr thanks for working on this! And apologies for not opening our impersonation impl earlier, as I promised. |
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
...-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastoreConfig.java
Outdated
Show resolved
Hide resolved
d6623de to
c808dee
Compare
findepi
left a comment
There was a problem hiding this comment.
A couple of comments. Well done!
presto-geospatial/src/test/java/io/prestosql/plugin/geospatial/TestSpatialJoins.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/authentication/HiveContext.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/authentication/HiveContext.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/HiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/cache/CachingHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftMetastore.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
this.impersonationEnabled = thriftConfig.isImpersonationEnabled() && hiveMetastoreAuthentication instanceof KerberosHiveMetastoreAuthentication;
the impersonation is supported only when kerberos is enabled
i think with setUGI, we should support impersonation with and without kerberos
-- but this also signals we don't have a direct test for an impersonation, something that would fail when impersonation does not work
There was a problem hiding this comment.
I think this should be visible if you add authorization here. (It should be included here anyway, it contains TestRoles, this is important to run here)
|
When applying changes, please separate them from rebase (or delay rebase), so that the changes themselves can be viewed on GH ui. |
electrum
left a comment
There was a problem hiding this comment.
Wow, adding impersonation for get calls was more complicated than I thought. Thanks for doing that.
presto-hive/src/main/java/io/prestosql/plugin/hive/CreateEmptyPartitionProcedure.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveMetadata.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HivePartitionManager.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/HivePartitionManager.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/HivePageSinkMetadataProvider.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/main/java/io/prestosql/plugin/iceberg/HiveTableOperations.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/main/java/io/prestosql/plugin/iceberg/IcebergMetadata.java
Outdated
Show resolved
Hide resolved
presto-iceberg/src/main/java/io/prestosql/plugin/iceberg/IcebergMetadata.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
I think this should be visible if you add authorization here. (It should be included here anyway, it contains TestRoles, this is important to run here)
There was a problem hiding this comment.
Any particular reason to include cli and hive_file_header tests?
(@kokosing do you know why do we run cli tests so often?)
There was a problem hiding this comment.
No particular reason to include those tests. I followed existing hdfs-impersonation tests.
c808dee to
525e514
Compare
|
Let me push updated code once. Below comments are not yet applied. |
presto-hive/src/main/java/io/prestosql/plugin/hive/HivePartitionManager.java
Outdated
Show resolved
Hide resolved
...to-hive/src/main/java/io/prestosql/plugin/hive/metastore/SemiTransactionalHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftMetastoreUtil.java
Outdated
Show resolved
Hide resolved
|
Pushed so that we can share the current status. |
presto-hive/src/main/java/io/prestosql/plugin/hive/HiveMetadataFactory.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/authentication/HiveIdentity.java
Outdated
Show resolved
Hide resolved
| implements HiveMetastore | ||
| { | ||
| protected final HiveMetastore delegate; | ||
| private final boolean impersonationEnabled; |
There was a problem hiding this comment.
We can remove this field if we add isImpersonationEnabled() to HiveMetastore. Then updateIdentity() can simply call delegate.isImpersonationEnabled().
There was a problem hiding this comment.
Should we always return false in FileHiveMetastore and throw an exception in GlueHiveMetastore? At least, we can't inject ThriftHiveMetastoreConfig into FileHiveMetastore. We can do it in GlueHiveMetastore.
There was a problem hiding this comment.
Yes, always false. we don't support impersonation there
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
|
I had a few comments, mostly around the usage of |
9736171 to
ed32e58
Compare
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/thrift/ThriftHiveMetastore.java
Outdated
Show resolved
Hide resolved
presto-hive/src/main/java/io/prestosql/plugin/hive/authentication/HiveIdentity.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Simply:
| this(new ConnectorIdentity("dummy_identity", Optional.empty(), Optional.empty())); | |
| this.username = "dummy_identity"; |
There was a problem hiding this comment.
Still, I'd prefer the username be Optional<String> in this class.
There is only one place where getUsername() is called, so it's not a big deal and improves clarify.
There was a problem hiding this comment.
HiveIdentity.none() is going to be used as a cache key many times at the same time, so using a singleton would be nice.
|
One more thing: we can remove |
ed32e58 to
2f64cbf
Compare
|
Actually I wonder how this is working, the set_ugi implementation in hive metastore server-side is like adding the user information in the session, and there is no additional impersonation or authentication implemented. In fact, the earlier version of implementation (delegation token based) looks pretty promising and follow what hive did internally. Have you guys tested this in the real secure hive metastore environment, for example, if you create a table, is it owned by the authenticated user (mostly presto) or the real impersonation user (end-user)? @ebyhr @findepi |
Fix #43