Hive的授权机制——基于存储的授权模型

原文:

https://cwiki.apache.org/confluence/display/Hive/Storage+Based+Authorization+in+the+Metastore+Server

 

Storage Based Authorization in the Metastore Server

Hive Metastore 服务中的基于存储的授权模型是在hive 0.10中加入的,这个特性已经在之前的版本中引入到了HCatalog

 

Metastore Server的安全必要性

当多个客户端去访问后台数据(如MySQL)中的同一元数据时,数据库的连接凭证信息会在hive-site.xml配置文件中显示的给出。此时,即使底层数据受到HDFS访问控制的保护,恶意用户或不称职的用户也可能对元数据造成严重损害。

此外,当Hive Metastore服务使用Thrift和客户端通信同时其有一个后台数据化用户存储和持久化元数据时,在客户端上执行的认证和授权并不能保证metastore侧的安全性。因此为了保障元数据的安全,Hive在0.10中为metastore服务添加了授权特性(见HIVE-3705)。

 

Storage Based Authorization

当metastore服务的安全性配置为使用 Storage Based Authorization 时,它就会使用与不同元数据对象对应的文件夹的文件系统权限作为授权策略的真实来源。推荐用户在metastore中使用Storage Based Authorization。

更多细节可以参考 Hcatalog 的  Storage Based Authorization document

从Hive 0.14 开始,Storage Based Authorization 授权数据库和表上的读取权限。get_database  API的调用需要数据库目录的读权限, 调用get_table_* 和 get_partition_* 以获取表信息和列出表的分区操作都需要有表目录的读权限。 Storage Based Authorization中该特性是默认启用的。相关配置见下面的 hive.security.metastore.authorization.auth.reads 配置项。

 

Metastore 安全的配置参数

为了使用Hive Metastore服务的安全特性,需要在hive-site.xml 文件中配置如下参数:

 

* hive.metastore.pre.event.listeners

设置为:

org.apache.hadoop.hive.ql.security.authorization.AuthorizationPreEventListener

这会开启metastore侧的安全特性。

 

* hive.security.metastore.authorization.manager

设置为:

org.apache.hadoop.hive.ql.security.authorization.StorageBasedAuthorizationProvider

该配置项用以metastore的授权管理器,这会告诉hive,metastore侧会提供哪种授权模型。该配置项的默认值是 DefaultHiveMetastoreAuthorizationProvider,它使用就是hive的传统授权模型(Hive grant/revoke)。

说明:StorageBasedAuthorizationProvider是在hive 0.10.0中加入的,但是它只能运行在metastore一侧,从Hive 0.12.0开始,也可以运行在客户端一侧了。

 

* hive.security.metastore.authenticator.manager

设置为

org.apache.hadoop.hive.ql.security.HadoopDefaultMetastoreAuthenticator

该配置项用以设置metastore的认证管理器。

 

* hive.security.metastore.authorization.auth.reads

当该配置选项设置为true时,Hive metastore授权同时会检查读权限。默认值是true,该特性是Hive0.14.0中引入的。

 

hive-site.xml 示例 :默认设置

下面的配置片段,是hive-site.xml中的默认配置,可以编辑相关的配置信息获得期望的授权模式。

<property>
  <name>hive.security.metastore.authorization.manager</name>
  <value>org.apache.hadoop.hive.ql.security.authorization.DefaultHiveMetastoreAuthorizationProvider</value>
  <description>authorization manager class name to be used in the metastore for authorization.
  The user defined authorization class should implement interface
  org.apache.hadoop.hive.ql.security.authorization.HiveMetastoreAuthorizationProvider.
  </description>
 </property>

<property>
  <name>hive.security.metastore.authenticator.manager</name>
  <value>org.apache.hadoop.hive.ql.security.HadoopDefaultMetastoreAuthenticator</value>
  <description>authenticator manager class name to be used in the metastore for authentication.
  The user defined authenticator should implement interface 
  org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider.
  </description>
</property>

<property>
  <name>hive.metastore.pre.event.listeners</name>
  <value> </value>
  <description>pre-event listener classes to be loaded on the metastore side to run code
  whenever databases, tables, and partitions are created, altered, or dropped.
  Set to org.apache.hadoop.hive.ql.security.authorization.AuthorizationPreEventListener
  if metastore-side authorization is desired.
  </description>
</property>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值