概述
简单的shell命令是Sentry用于管理元数据的命令行工具,比如:
bin/sentryShell --grant_role_privilege --role analyst --privilege server=server1->db=db2->table=tab1->action=select --conf sentry-site.xml
Shell命令目前仅限于Hive授权元数据,支持一下命令:
- 添加/删除角色(create/drop role)
- 从角色中添加删除组(create/drop role)
- 授予/撤销角色的授权(grant/revoke privilege to/from role)
- 列出组的角色(list role for group)
- 列出角色的权利(list privilege for role)
关于用户,组,角色的相关概念可以阅读基于角色的访问控制。
创建角色
用指定角色名创建角色,例如:
bin/sentryShell -cr -r <role name> -conf <the path for sentry configuration file>
或者
bin/sentryShell --create_role -r <role name> -conf <the path for sentry configuration file>
注意:conf参数需要设置为sentry的配置文件路径
删除角色
用指定角色名删除角色,例如:
bin/sentryShell -dr -r <role name> -conf <the path for sentry configuration file>
或者
bin/sentryShell --drop_role -r <role name> -conf <the path for sentry configuration file>
为组添加角色
用指定的组名和角色名为组添加角色,或者理解为用指定的组名和角色名将组添加到角色,如:
bin/sentryShell -arg -r <role name> -g <group name> -conf <the path for sentry configuration file>
或者
bin/sentryShell --add_role_group -r <role name> -g <group name> -conf <the path for sentry configuration file>
删除组的角色
用指定的组名和角色名将组的某角色删除,或理解为从具有给定组名和角色名的角色中删除组,如:
bin/sentryShell -drg -r <role name> -g <group name> -conf <the path for sentry configuration file>
或者
bin/sentryShell --delete_role_group -r <role name> -g <group name> -conf <the path for sentry configuration file>
为角色授权
通过指定的授权语句和角色名为角色授权。
标准的授权语句: server=serverName->db=databaseName->table=tableName->column=columnName->action=actionName
如:
bin/sentryShell -gpr -r <role name> -p <privilege string> -conf <the path for sentry configuration file>
或者
bin/sentryShell --grant_privilege_role -r <role name> -p <privilege string> -conf <the path for sentry configuration file>
撤销角色的授权 ##
用指定的角色名和撤销授权语句撤销角色的授权,如:
bin/sentryShell -rpr -r <role name> -p <privilege string> -conf <the path for sentry configuration file>
或者
bin/sentryShell --revoke_privilege_role -r <role name> -p <privilege string> -conf <the path for sentry configuration file>
角色清单
用指定的组名列出该组拥有的角色或者直接列出现在已有的所有角色,如:
bin/sentryShell -lr -conf <the path for sentry configuration file>
bin/sentryShell -lr -g <group name> -conf <the path for sentry configuration file>
或者
bin/sentryShell --list_role -conf <the path for sentry configuration file>
bin/sentryShell --list_role -g <group name> -conf <the path for sentry configuration file>
列出角色授权
List the privileges with the given role name.
用指定的角色名列出该角色拥有的授权,如:
bin/sentryShell -lp -r <role name> -conf <the path for sentry configuration file>
或者
bin/sentryShell --list_privilege -r <role name> -conf <the path for sentry configuration file>
帮助
显示帮助信息,如:
bin/sentryShell -h
或者
bin/sentryShell --help