To better use hive, I took out the security section of Programming hive and translated it.
Hive also supports quite a few rights management functions to meet the general Data Warehouse usage.
Hive configures the default permissions for new files by a default setting.
XML code
- <property>
- <name>hive.files.umask.value</name>
- <value>0002</value>
- <description>the dfs.umask value for the hive created folders</description> /c4>
- </Property>
<property> <name>hive.files.umask.value</name> <value>0002</value> <description>the Dfs.umask value for the hive created folders</description></property>
When the Hive.metastore.authorization.storage.checks property is set to True,
Hive will prevent a user who does not have permissions from doing a table delete operation.
However, the default value for this configuration is false and should be set to True
XML code
- <property>
- <name>hive.metastore.authorization.storage.checks</name>
- <value>true</value>
- <description>should The Metastore do authorization checks against
- The underlying storage for operations like Drop-partition (disallow
- The drop-partition if the user in question doesn ' t has permissions
- To delete the corresponding directory on the storage). </Description>
- </Property>
<property> <name>hive.metastore.authorization.storage.checks</name> <value> True</value> <description>should The Metastore do authorization checks against the underlying Storage for operations like Drop-partition (disallow the drop-partition if the user in question doesn ' t has Permissio NS to delete the corresponding directory on the storage) .</description></property>
At the same time, Hive will set the Hive.metastore.execute.setugi to true as much as possible.
Turn on the identity authentication function of hive, default is False
XML code
- <property>
- <name>hive.security.authorization.enabled</name>
- <value>true</value>
- <description>enable or disable the Hive client authorization</Description>
- </Property>
<property> <name>hive.security.authorization.enabled</name> <value>true</ value> <description>enable or disable the hive client Authorization</description></property >
There is also a permission configuration item that is used by the table creator:
XML code
- <property>
- <name>hive.security.authorization.createtable.owner.grants</name>
- <value>all</value>
- <description>the privileges automatically granted to the owner whenever
- A table gets created. An example-like "Select,drop" would grant Select
- and drop privilege to the owner of the table</description>
- </Property>
<property> <name>hive.security.authorization.createtable.owner.grants</name> < Value>all</value> <description>the privileges automatically granted to the owner whenever a Table gets created. An example-like "Select,drop" would grant select and drop privilege to the owner of the table</description></p Roperty>
This configuration is null by default, and we recommend that you set it to all so that users can access the tables that they create.
testing, enabling user authentication on the command line environment
Shell Code
- Hive> set hive.security.authorization.enabled=true;
- Hive> CREATE TABLE authorization_test (key int, value string);
- Authorization failed:no Privilege ' Create ' found for outputs {Database:default}.
- Use show grant to get more details.
Hive> set hive.security.authorization.enabled=true;hive> CREATE TABLE authorization_test (key int, value string); Authorization failed:no privilege ' Create ' found for outputs {Database:default}. Use show grant to get more details.
As we can see, building the table requires permission.
Permissions can be granted to different topics, such as user, Group, role (ROLES)
Now we grant permissions to the current user through authorization:
Shell Code
- Hive> set System:user.name;
- System:user.name=edward
- Hive> GRANT CREATE on DATABASE default to USER Edward;
- Hive> CREATE TABLE authorization_test (key INT, value STRING);
Hive> set system:user.name;system:user.name=edwardhive> GRANT CREATE on DATABASE default to user edward;hive> CR Eate TABLE authorization_test (key INT, value STRING);
This makes it possible to create a table.
We can confirm the permissions we have with the show Grant command:
Shell Code
- hive> SHOW GRANT USER Edward on DATABASE default;
- Database default
- PrincipalName Edward
- Principaltype USER
- Privilege Create
- Granttime Mon Mar ::EDT
- Grantor Edward
hive> SHOW GRANT USER Edward on DATABASE default;database defaultprincipalname edwardprincipaltype userprivilege Creat Egranttime Mon Mar 09:18:10 EDT 2012grantor Edward
When hive is used for n multiple users and N tables, the administrator authorizes each user to crash each table.
Therefore, the group authorization can be performed at this time.
The definition of a user group in hive is equivalent to a user group within POSIX.
Shell Code
- Hive> create table authorization_test_group (a int,b int );
- hive> select * from authorization_test_group;
- Authorization failed:no privilege ' Select ' found for inputs
- { database:default, table:authorization_test_group, columnname:a}.
- use show grant to get more details.
- hive> grant select on table authorization_test_group to group Edward
- hive> select * from authorization_test_group;
- OK
- time taken: 0.119&NBSP;SECONDS&NBSP;&NBSP;
Hive> CREATE TABLE authorization_test_group (a int,b int);hive> SELECT * from Authorization_test_group; Authorization failed:no privilege ' Select ' found for inputs{Database:default, Table:authorization_test_group, COLUMNNAME:A}. Use show grant to get more details.hive> grant SELECT on table Authorization_test_group to group edward;hive> SELECT * FROM Authorization_test_group;oktime taken:0.119 seconds
Roles (ROLES) are used when authorization to user groups becomes inflexible.
The user can be placed in a role, and the role can be authorized.
Roles are different from user groups and are controlled by Hadoop and are managed internally by Hive.
Shell Code
- Hive> CREATE TABLE authentication_test_role (a int, b int);
- Hive> SELECT * from Authentication_test_role;
- Authorization failed:no Privilege ' Select ' found for inputs
- {database:default, Table:authentication_test_role, columnname:a}.
- Use show grant to get more details.
- hive> CREATE ROLE Users_who_can_select_authentication_test_role;
- Hive> GRANT ROLE users_who_can_select_authentication_test_role to USER Edward;
- Hive> GRANT SELECT on TABLE authentication_test_role
- > to ROLE users_who_can_select_authentication_test_role;
- Hive> SELECT * from Authentication_test_role;
- Ok
- Time taken: 0.103 seconds
Hive> CREATE TABLE authentication_test_role (a int, b int);hive> SELECT * from Authentication_test_role; Authorization failed:no privilege ' Select ' found for inputs{Database:default, Table:authentication_test_role, COLUMNNAME:A}. Use show grant to get more details.hive> CREATE role users_who_can_select_authentication_test_role;hive> Grant role Users_who_can_select_authentication_test_role to USER edward;hive> GRANT Select on TABLE authentication_test_role > To ROLE users_who_can_select_authentication_test_role;hive> select * from Authentication_test_role;oktime taken:0.103 seconds
Introduce the commonly used authorization keywords:
Alter |
Change table structure, create partitions |
CREATE |
Create a table |
DROP |
Delete a table, or partition |
INDEX |
Creating and deleting indexes |
LOCK |
Lock the table to ensure concurrency |
SELECT |
Query table Permissions |
Show_database |
View Database Permissions |
UPDATE |
Permissions to load local data for a table |
Partition Table-Level authorization
By default, the authorization of the partitioned table will follow the table's authorization
Of course, you can also create an authorization mechanism for each partition,
Just set the properties of the table Partition_level_privilege set to True:
Shell Code
- hive> ALTER TABLE Authorization_part
- > SET tblproperties ("partition_level_privilege" ="TRUE");
- Authorization failed:no Privilege ' Alter ' found for inputs
- {Database:default, Table:authorization_part}.
- Use show grant to get more details.
hive> ALTER TABLE authorization_part> SET tblproperties ("partition_level_privilege" = "TRUE"); Authorization failed:no privilege ' Alter ' found for Inputs{database:default, Table:authorization_part}. Use show grant to get more details.
Automatic authorization
The attribute hive.security.authorization.createtable.owner.grants determines
The table owner has permissions to the table, and in the case of a version, select and drop
XML code
- <property>
- <name>hive.security.authorization.createtable.owner.grants</name>
- <value>select,drop</value>
- </Property>
<property> <name>hive.security.authorization.createtable.owner.grants</name> < Value>select,drop</value></property>
Similarly, a particular user can be granted permissions automatically when the table is created.
XML code
- <property>
- <name >hive.security.authorization.createtable.user.grants</name>
- <value>admin1,edward:select;user1:create</ value>
- </property>
<property> <name>hive.security.authorization.createtable.user.grants</name> < Value>admin1,edward:select;user1:create</value></property>
When the table was established, Administrator Admin1 and user Edward granted permission to read all the tables.
Instead, User1 can only create tables.
The same configuration can also be used for group authorization and role authorization
Hive.security.authorization.createtable.group.grants
Hive.security.authorization.createtable.role.grants
Transfer from http://dacoolbaby.iteye.com/blog/1829545
Security Configuration for Hive