Ranger configuration strategy (four) (2)

Configure a resource-based strategy: Hive

How to add new strategies to existing Hive services.

process

  1. .On the "Service Manager" interface, select an existing Hive service.
    The "Policy List" page appears.
  2. Click "Add New Policy."
    The system displays the "Create Policy" page.
    Insert picture description here
  3. Follow the steps below to complete the "Create Policy" page:

Table policy details

Field description
Policy Name Enter the appropriate policy name. This name cannot be repeated in the system. This field is required. By default, this policy is enabled.
normal/override Allows you to specify the coverage strategy. When "Overwrite" is selected, the access rights in the policy will overwrite the access rights in the existing policy. This feature can be used together with "Add Validity Period" to create temporary access policies that override existing policies.
Database Type the applicable database name. The auto complete feature displays the available databases based on the entered text. By default, contains is selected to allow access. Select Exclude to deny access.
table / udf Specify a table-based or udf-based strategy. Select table or udf, and then type in the applicable table or udf name. The autocomplete feature displays the available tables based on the entered text. By default, contains is selected to allow access. Select Exclude to deny access.
Hive Column Enter the applicable Hive column name. The autocomplete feature displays the available columns based on the entered text. By default, contains is selected to allow access. Select Exclude to deny access. If you use the Ranger Hive plugin with HiveServer2 or HiveServer2llap and the column or description permissions include all, you must set a parameter for the Hive column to display it as expected: in Ambari>Hive, under Ranger-Hive -security. Then enter: xasecure.hive.describetable.showcolumns.authorization.option=showall. If the setting fails, a HiveAccessControlException error will be prompted
URL Specify the cloud storage path (for example, s3a://devadmin/demo/campaign.txt), which requires the end user to have read and write permissions for the Hive data on /. Permission: The read operation of the URL allows users to perform HiveServer2 operations on the Hive table with S3 as the data source. The write operation to the URL allows the user to perform the HiveServer2 operation and write the data to the specified location in S3. This feature is a technology preview: it is not yet available for production deployment.
HATE Hive INSERT OVERWRITE queries require a Ranger URI policy to allow write operations, even if the user has granted write permissions through the HDFS policy. If you fail to specify this field, the following error will occur: error while compiling statement: FAILED: HiveAccessControlException Permission denied: user [jdoe] does not have [WRITE] privilege on [/tmp/ ] (state=42000,code=40000) Example :/tmp/
Description (Optional) Describe the purpose of this policy. If you use the Ranger Hive plugin together with HiveServer2 or HiveServer2- llap, and the column or description permissions include all, you must set a parameter for the Hive column to display it as expected: in Ambari>Hive, in Ranger-Hive -security under. In xml, enter: xasecure.hive.describetable.showcolumns.authorization.option =show all. If the setting fails, a HiveAccessControlException error will be prompted.
Hive Service Name hiveservice can only be used with Permissions=Service Admin. Allow users with service management rights in Ranger to run kill query API: kill query. Support value:*. (Required)
Audit Logging Specify whether to audit this policy. (Deselect to disable auditing).
Policy Label Assign a label to the policy. You can search reports and filter strategies based on these tags.
Add Validity Period Specify the start and end time of the strategy.

Table 2 Allowable conditions

label description
Select Group Specify the group to which this policy applies. To designate a group as an administrator, select the "Delegate Administrators" checkbox. The administrator can edit or delete the policy, or create a sub-policy based on the original policy. The public group contains all users, so granting access to the public group will grant access to all users.
Select User Specify the users to whom this policy applies. To designate a user as an administrator, select the "Delegate Administrator" check box. The administrator can edit or delete the policy, or create a sub-policy based on the original policy.
Permissions 添加或编辑权限:选择,更新,创建,删除,修改,索引,锁定,所有,ReplAdmin,服务管理员,选择/取消选择所有。如果使用Ranger Hive plugin与HiveServer2或HiveServer2- llap一起使用,其中的列或描述权限包括all,则必须为Hive列设置一个参数,使其按预期显示:在Ambari>Hive中,在Ranger - Hive -security下。然后 输入:xasecure.hive.describetable.showcolumns.authorization.option=show all。设置该参数失败将导致错误消息HiveAccessControlException。在执行repl dump、repl load和repl status命令时,必须设置一个参数:在Ambari>Hive中,在Hive -site. sh目录下。xml输入:hive.distcp.privileged.doAs =hive。Service Admin与Hive Service Name和kill query API一起使用:kill query
Delegate Admin 您可以使用Delegate Admin为策略中指定的用户或组分配管理员权限。管理员可以编辑或删除策略,也可以在原始策略的基础上创建子策略。
  1. 您可以使用加号(+)来添加额外的条件。条件按照策略中列出的顺序进行评估。首先应用列表顶部的条件,然后是第二个条件,然后是第三个条件,依次类推。
  2. 单击Add。

What to do next

通过命令行提供用户对Hive数据库表的访问Hive提供了通过命令行直接管理用户对Hive数据库表访问的方法。最常用的命令有:

• 授予
语法

grant <permissions> on table <table> to user <user or group>;

例如,要创建一个对default-hivesmoke22074表授予user1 SELECT权限的策略,命令应该是:

grant select on table default.hivesmoke22074 to user user1;

授予UPDATE、CREATE、DROP、ALTER、INDEX、LOCK、ALL和ADMIN权限的语法是相同的。

• 撤消
语法

revoke <permissions> on table <table> from user <user or group>;

例如,撤销user1对表default的选择权限。hivesmoke22074,命令如下:

revoke select on table default.hivesmoke22074 from user user1;

```配置一个基于资源的策略:Kafka

如何添加一个新的策略到现有的Kafka服务。

过程

  1. 在“服务管理器”页面中,选择已存在的Kafka服务。
    出现“策略列表”页面。

  2. 单击“添加新策略”。
    系统显示“创建策略”页面。
    Insert picture description here

  3. 按照如下步骤完成“创建策略”页面:

表一:策略细节

字段 描述
Policy Name 输入适当的策略名称。此名称不能在系统中重复。该字段为必填项。
normal/override 允许您指定覆盖策略。选择“覆盖”时,策略中的访问权限将覆盖已有策略中的访问权限。该特性可与“添加有效期”一起使用,创建覆盖现有策略的临时访问策略。
Solr Collection 对于HDP搜索的Solr实例:http:host_ip:8983/ Solr ;对于Ambari Infra的Solr实例:http:host_ip:8886/ Solr
Description (可选)描述本政策的目的。
Audit Logging 指定是否审计此策略。(取消选择,禁用审计)。
Policy Label 为该策略指定一个标签。您可以根据这些标签搜索报表和筛选策略。
Add Validity Period 指定策略的开始和结束时间。
Policy Conditions (applied at the policy level) 单击+图标,然后指定一个IP地址范围。

表二:允许条件

标签 描述
Select Group 指定应用此策略的组。要将一个组指定为管理员,请选中“委派管理员”复选框。管理员可以编辑或删除策略,也可以在原始策略的基础上创建子策略。public组包含所有用户,因此授予对public组的访问权限将授予所有用户的访问权限。
Select User 指定应用此策略的用户。若要将用户指定为管理员,请选中“委派管理员”复选框。管理员可以编辑或删除策略,也可以在原始策略的基础上创建子策略。
Policy Conditions (applied at the item level) 请指定IP地址范围。
Permissions 添加或编辑权限:查询、更新、其他、Solr Admin、选择/取消选择所有。
Delegate Admin 您可以使用Delegate Admin为策略中指定的用户或组分配管理员权限。管理员可以编辑或删除策略,也可以在原始策略的基础上创建子策略。
  1. 您可以使用加号(+)来添加额外的条件。条件按照策略中列出的顺序进行评估。首先应用列表顶部的条件,然后是第二个条件,然后是第三个条件,依次类推。
  2. 单击Add。

配置一个基于资源策略:YARN

如何向现有YARN服务添加新策略。

过程

  1. 在“服务管理器”界面中,选择已存在的YARN服务。
    出现“策略列表”页面。

  2. 单击“添加新策略”。
    系统显示“创建策略”页面。

Insert picture description here
3.按照如下步骤完成“创建策略”页面:

表1:策略详细信息

字段 描述
Policy Name 输入适当的策略名称。此名称不能在系统中重复。该字段为必填项。
normal/override 允许您指定覆盖策略。选择“覆盖”时,策略中的访问权限将覆盖已有策略中的访问权限。该特性可与“添加有效期”一起使用,创建覆盖现有策略的临时访问策略。
Queue 策略应用到的YARN队列。
Recursive 默认递归设置指定该策略也将应用于所有子队列;还可以指定非递归路径。
Description (可选)描述本政策的目的。
Audit Logging 指定是否审计此策略。(取消勾选“禁用审计”)。
Policy Label 为该策略指定一个标签。您可以根据这些标签搜索报表和筛选策略。
Add Validity Period 指定策略的开始和结束时间。

表二:允许条件

标签 属性
Select Group 指定应用此策略的组。要将一个组指定为管理员,请选中“委派管理员”复选框。管理员可以编辑或删除策略,也可以在原始策略的基础上创建子策略。public组包含所有用户,因此授予对public组的访问权限将授予所有用户的访问权限。
Select User 指定应用此策略的用户。若要将用户指定为管理员,请选中“委派管理员”复选框。管理员可以编辑或删除策略,也可以在原始策略的基础上创建子策略。
Permissions 添加或编辑权限:提交-应用程序,管理-队列,选择/取消选择所有。
Delegate Admin 您可以使用Delegate Admin为策略中指定的用户或组分配管理员权限。管理员可以编辑或删除策略,也可以在原始策略的基础上创建子策略。
  1. 点击添加

基于资源的策略中的通配符和变量*(imp)

基于资源策略中的通配符和变量引用基于资源策略中的通配符和变量。管理员授权资源策略通配符通配符可以包含在资源路径、数据库名、表名或列名中:
•*表示零次或多次出现字符
•?表示单个字符
管理员授权资源策略{USER}变量,变量{USER}可用于自动填充正在访问的用户,例如:
在“选择用户”中选择“{User}”。
在“资源路径”中输入data_{USER}。
管理员授权资源策略{USER}变量,推荐的实践和可定制性管理员要求使用字符串’{USER}‘表示访问用户作为管理员策略中的策略项中的用户。但是,Ranger提供了灵活的定制字符串的方法,该字符串在策略资源规范中用作表示访问用户名的简写。默认情况下,管理员政策资源规范预计字符“{”和“}”作为分隔符字符串“用户”,然而,管理员支持可定制的方式指定分隔符字符,逃离这些分隔符和字符串“用户”本身在它前面加上与另一个指定的字符串在每个资源级别的基础上在每个组件的服务定义得到管理员的支持。
例如,对于某个HDFS安装,如果路径名可能包含’{‘或’}‘作为有效字符,而不是’%'字符,那么HDFS的服务定义可以指定为:

"resources": [
{
    
    
"itemId": 1,
 "name": "path",
 "type": "path",
 "level": 10,
 "parent": "",
 "mandatory": true,
 "lookupSupported": true,
 "recursiveSupported": true,
 "excludesSupported": false,
 "matcher":
 "org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
 "matcherOptions": {
    
    "wildcard": true, "ignoreCase": false},
 "replaceTokens":true, "tokenDelimiterStart":"%", "tokenDelimiterEnd":"%",
 "tokenDelimiterPrefix":"rangerToken:"}
 "validationRegEx":"",
 "validationMessage": "",
 "uiHint":"",
 "label": "Resource Path",
 "description": "HDFS file or directory
path"
}]```

HDFS用例对应的ranger策略如下所示:

resource: path=/home/%rangerToken:USER%
user: {
    
    USER}
permissions: all, delegateAdmin=true

The following customizable matcherOptions can be used for this function:
• replaceTokens: If the abbreviation of user in the resource-spec needs to be replaced with the name of the current user at runtime, it is true; if the resource specification needs to be explained as it is, it is false. Default value: true.
•TokenDelimiterStart: Identifies the start character of the current user in the resource specification. Defaults:{.
•TokenDelimiterEnd: Identifies the abbreviated end character of the current user in the resource specification. The default
value:}.
• tokenelimiterescape: the escape character used to escape tokenelimiterstart or tokenelimiterend values
in the resource specification. Defaults:\.
•TokenDelimiterPrefix: Identifies a special prefix, which together with the string "USER" constitutes the abbreviation of the current user name in the resource specification. Defaults:.

Guess you like

Origin blog.csdn.net/m0_48187193/article/details/114686377