...
● ALL PRIVILEGES - gives all privileges
Objects
● The privileges will apply to table and views. The above privileges are not supported on databases.
...
For certain actions, the ownership of the object (table/view/database) determines if you are authorized to perform the action.
Users and Roles
Privileges can be granted to users as well as roles.
Users can belong to one or more roles.
There are two roles with special meaning - *public* and *admin*.
All users belong to the *public* role. You use this role in your grant statement to grant the privilege to all users.
When a user runs a hive query/command, the privileges granted to the user and her ‘current roles’ are checked. The current roles can be seen using the ‘show current roles;’ command. All roles except for the *admin* role will be in the current roles by default.
To set a specific role as the current role, you need to use the ‘set role’ command. See the command description for details.
Users who do the work of a ‘data base administrator’ are expected to be added to the *admin* role.
They have privileges for running additional commands such as ‘create role’ and ‘drop role’. They can also access objects that they haven’t been given explicit access to. However, a user who belongs to the admin role needs to run the ’SET ROLE’ command before getting the privileges of the admin role, as this role is not in current roles by default.
Role names are case insensitive. ie, “marketing” and “MarkEting” refer to same role.
User names are case sensitive. This is because, unlike role names, user names are not managed within hive.
Role management commands
CREATE ROLE <rolename>;
Creates a new role. Only admin role has privilege for this.
The role names ALL, DEFAULT and NONE are reserved.
DROP ROLE <rolename>;
Drops the given role. Only admin role has privilege for this.
SHOW CURRENT ROLES;
Shows the list of current roles. All actions of the user are authorized by looking at the privileges of the user and all current roles of the user.
The default current roles has all roles for the user except for the admin role (even if the user belongs to the admin role as well).
Any user can run this command.
SET ROLE (<rolename>|ALL)
If a <rolename> is specified, then that role becomes the only role in current roles.
Setting role name to ALL refereshes the list of current roles (in case new roles were granted to the user) and sets them to default list of roles.
If a role the user does not belong to is specified as the <rolename>, it will result in an error.
* SHOW ROLES
List all currently existing roles.
Only admin role has privilege for this.
* GRANT ROLE <role_name> [, <role_name>] ...
TO principal_specification [, principal_specification] ...
[ WITH ADMIN OPTION ]
principal_specification
: USER user
| ROLE role
Grant one or more roles to other roles or users.
If “WITH ADMIN OPTION” is specified, then the user gets privileges to grant the role to other users/roles.
If the grant statement ends up creating a cycling relationship between roles, the command will fail with an error.
* REVOKE ROLE <role_name> [, <role_name>] ...
FROM principal_specification [, principal_specification] ...
principal_specification
: USER user
| ROLE role
Revokes the membership of the roles from the user/roles in the FROM clause.
Currently revoking just the ADMIN OPTION is not possible. You need to revoke the principal’s role grant, and then grant the role to principal without admin option.
* SHOW ROLE GRANT (USER|ROLE) <principalname>
Where principal name is the name of a user or role.
Lists all roles the given user or role has been granted.
Currently any user can run this command. But this is likely to change in future to allow users to see only their own role grants, and additional privileges would be needed to see role grants of other users.
0: jdbc:hive2://localhost:10000> GRANT role1 TO USER user1 ;
No rows affected (0.058 seconds)
0: jdbc:hive2://localhost:10000> SHOW ROLE GRANT USER user1
+---------+---------------+----------------+----------+
| role | grant_option | grant_time | grantor |
+---------+---------------+----------------+----------+
| public | false | 0 | |
| role1 | false | 1398284083000 | uadmin |
+---------+---------------+----------------+----------+
* SHOW PRINCIPALS <rolename>
Lists all roles and users who belong to this role.
Only admin role has privilege for this.
0: jdbc:hive2://localhost:10000> SHOW PRINCIPALS role1;
+-----------------+-----------------+---------------+----------+---------------+----------------+
| principal_name | principal_type | grant_option | grantor | grantor_type | grant_time |
+-----------------+-----------------+---------------+----------+---------------+----------------+
| role2 | ROLE | false | uadmin | USER | 1398285926000 |
| role3 | ROLE | true | uadmin | USER | 1398285946000 |
| user1 | USER | false | uadmin | USER | 1398285977000 |
+-----------------+-----------------+---------------+----------+---------------+----------------+
Configuration
References
...