How-to: Enable User Authentication and Authorization in Apache HBase

本文探讨了如何使用Kerberos为Hadoop和HBase提供用户认证,并介绍了HBase如何实施用户授权来授予特定用户对特定数据集的操作权限。此外,还讨论了通过配置防火墙和使用SASL进行加密协商等措施加强安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

With the default Apache HBase configuration, everyone is allowed to read from and write to all tables available in the system. For many enterprise setups, this kind of policy is unacceptable. 

Administrators can set up firewalls that decide which machines are allowed to communicate with HBase. However, machines that can pass the firewall are still allowed to read from and write to all tables.  This kind of mechanism is effective but insufficient because HBase still cannot differentiate between multiple users that use the same client machines, and there is still no granularity with regard to HBase table, column family, or column qualifier access.

In this post, we will discuss how Kerberos is used with Hadoop and HBase to provide User Authentication, and how HBase implements User Authorization to grant users permissions for particular actions on a specified set of data.

Secure HBase: Authentication & Authorization

A secure HBase aims to protect against sniffers, unauthenticated/unauthorized users and network-based attacks. It does not protect against authorized users who accidentally delete all the data. 

HBase can be configured to provide User Authentication, which ensures that only authorized users can communicate with HBase. The authorization system is implemented at the RPC level, and is based on the Simple Authentication and Security Layer (SASL), which supports (among other authentication mechanisms) Kerberos. SASL allows authentication, encryption negotiation and/or message integrity verification on a per connection basis ( “hbase.rpc.protection” configuration property).

The next step after enabling User Authentication is to give an admin the ability to define a series of User Authorization rules that allow or deny particular actions. The Authorization system, also known as the Access Controller Coprocessor or Access Control List (ACL), is available from HBase 0.92 (CDH4) onward and gives the ability to define authorization policy (Read/Write/Create/Admin), with table/family/qualifier granularity, for a specified user.

Kerberos

Kerberos is a networked authentication protocol. It is designed to provide strong authentication for client/server applications by using secret-key cryptography. The Kerberos protocol uses strong cryptography (AES, 3DES, …) so that a client can prove its identity to a server (and vice versa) across an insecure network connection. After a client and server have used Kerberos to prove their identities, they can also encrypt all of their communications to assure privacy and data integrity as they go about their business.

Ticket exchange protocol

At a high level, to access a service using Kerberos, each client must follow three steps:

  • Kerberos Authentication: The client authenticates itself to the Kerberos Authentication Server and receive a Ticket Granting Ticket (TGT).
  • Kerberos Authorization: The client request a service ticket from the Ticket Granting Server, which issues a ticket and a session key if the client TGT sent with the request is valid.
  • Service Request: The client uses the service ticket to authenticate itself to the server that is providing the service the client is using (e.g. HDFS, HBase, …)

HBase, HDFS, ZooKeeper SASL

Since HBase depends on HDFS and ZooKeeper, secure HBase relies on a secure HDFS and a secure ZooKeeper. This means that the HBase servers need to create a secure service session, as described above, to communicate with HDFS and ZooKeeper.

All the files written by HBase are stored in HDFS. As in Unix filesystems, the access control provided by HDFS is based on users, groups and permissions.  All the files created by HBase have “hbase” as user, but this access control is based on the username provided by the system, and everyone that can access the machine is potentially able to “sudo” as the user “hbase”. Secure HDFS adds the authentication steps that guarantee that the “hbase” user is trusted.

ZooKeeper has an Access Control List (ACL) on each znode that allows read/write access to the users based on user information in a similar manner to HDFS.

HBase ACL

Now that our users are authenticated via Kerberos, we are sure that the username that we received is one of our trusted users.  Sometimes this is not enough granularity – we want to control that a specified user is able to read or write a table. To do that, HBase provides an Authorization mechanism that allows restricted access for specified users.

To enable this feature, you must enable the Access Controller coprocessor, by adding it to hbase-site.xml under the master and region server coprocessor classes. (See how to setup the HBase security configuration here.)

A coprocessor is code that runs inside each HBase Region Server and/or Master.  It is able to intercept most operations (put, get, delete, …), and run arbitrary code before and/or after the operation is executed. 

Using this ability to execute some code before each operation, the Access Controller coprocessor can check the user rights and decide if the user can or cannot execute the operation.

Rights management and _acl_ table

The HBase shell has a couple of commands that allows an admin to manage the user rights:

  • grant [table] [family] [qualifier]
  • revoke [table] [family] [qualifier]

As you see, an admin has the ability to restrict user access based on the table schema:

  • Give User-W only read rights to Table-X/Family-Y (grant ‘User-W’ ‘R’ ‘Table-X’, ‘Family-Y’)
  • Give User-W the full read/write rights to Qualifier-Z (grant ‘User-W’ ‘RW’ ‘Table-X’, ‘Family-Y’, ‘Qualifier-Z’)

An admin also has the ability to grant global rights, which operate at the cluster level, such as creating tables, balancing regions, shutting down the cluster and so on:

  • Give User-W the ability to create tables (grant ‘User-W’, ‘C’)
  • Give User-W the ability to manage the cluster (grant ‘User-W’, ‘A’)

All the permissions are stored in a table created by the Access Controller coprocessor, called _acl_. The primary key of this table is the table name that you specify in the grant command. The _acl_ table has just one column family and each qualifier describes the granularity of rights for a particular table/user.  The value contains the actual rights granted.

As you can see, the HBase shell commands are tightly related to how the data is stored. The grant command adds or updates one row, and the revoke command removes one row from the _acl_ table.

Access Controller under the hood

As mentioned previously, the Access Controller coprocessor uses the ability to intercept each user request, and check if the user has the rights to execute the operations.

For each operation, the Access Controller needs to query the _acl_ table to see if the user has the rights to execute the operation.

However, this operation can have a negative impact on performance. The solution to fix this problem is using the _acl_ table for persistence and ZooKeeper to speed up the rights lookup. Each region server loads the _acl_ table in memory and get notified of changes by the ZkPermissionWatcher. In this way, every region server has the updated value every time and each permission check is performed by using an in-memory map. 

Roadmap

While Kerberos is a stable, well-tested and proven authentication system, the HBase ACL feature is still very basic and its semantics are still evolving. HBASE-6096 is the umbrella JIRA as reference for all the improvements to ship in a v2 of the ACL feature.

Another open topic on authorization and access control is implementing a per-KeyValue security system (HBASE-6222) that will give the ability to have different values on the same cell associated with a security tag. That would allow to showing a particular piece of information based on the user’s permissions.

Conclusion

HBase Security adds two extra features that allow you to protect your data against sniffers or other network attacks (by using Kerberos to authenticate users and encrypt communications between services), and allow you to define User Authorization policies, restrict operations, and limit data visibility for particular users. 

Matteo Bertozzi is a Software Engineer at Spotify and an HBase Consultant at Cloudera. 

Ref: http://blog.cloudera.com/blog/2012/09/understanding-user-authentication-and-authorization-in-apache-hbase/

<think>我们正在配置网络设备的本地管理账户和AAA认证授权模板。根据引用内容,配置步骤如下:1.**创建本地用户**:使用`local-user`命令创建本地用户,并设置密码和权限级别。 2. **配置AAA方案**:包括认证方案、授权方案和计费方案(如果不需要计费,可以跳过计费方案配置)。 3. **配置域**:在域下应用认证、授权和计费方案(对于本地认证,通常使用默认域`system`)。具体步骤:###1.创建本地用户进入系统视图,创建本地用户(例如用户名为admin),设置密码和权限级别(3级为最高权限):```bashsystem-viewlocal-useradmin classmanagepassword simpleyour_password#设置简单密码,或使用cipher加密authorization-attribute user-role level-3#设置权限级别为3service-typeterminal#设置用户服务类型为终端接入(如telnet、ssh) ```###2.配置AAA认证方案(本地认证) 创建认证方案并配置为本地认证: ```bashaaaauthentication-scheme local_auth#创建认证方案,名称自定义authentication-mode local#认证模式为本地认证```###3.配置AAA授权方案(本地授权) 创建授权方案并配置为本地授权:```bashauthorization-schemelocal_author#创建授权方案,名称自定义authorization-modelocal#授权模式为本地授权``` ###4.配置域并应用方案在域(如默认域`system`)下应用认证方案和授权方案:```bashdomainsystem#进入系统默认域authentication-schemelocal_auth#应用认证方案authorization-scheme local_author#应用授权方案```###5.配置用户接口(如Console、VTY)的认证方式对于Console口(con0),建议使用认证模式为`none`(不需要认证)或`password`(密码认证),但为了安全,通常设置密码认证。例如: ```bashuser-interface con0authentication-modescheme#使用AAA认证方案(即上面配置的本地认证)``` 对于VTY(虚拟终端)接口,配置为使用AAA认证方案: ```bashuser-interface vty04#进入VTY0到4authentication-mode scheme#使用AAA认证方案``` ###注意事项-如果同时配置了RADIUS和本地认证,可以在认证方案中配置备份认证方式(如`authentication-mode radiuslocal`,表示先尝试RADIUS认证,失败后使用本地认证)。-计费方案在本地认证中通常不需要配置,因为计费一般由RADIUS服务器完成。###配置示例(综合) ```bashsystem-view#创建本地用户local-user adminclass managepasswordsimple Admin@123authorization-attribute user-rolelevel-3service-typeterminal#配置AAA认证方案aaaauthentication-schemelocal_authauthentication-mode local#配置AAA授权方案authorization-scheme local_authorauthorization-modelocal#在system域下应用domain systemauthentication-schemelocal_authauthorization-scheme local_author#配置用户接口认证user-interface con0authentication-modescheme#使用AAA认证user-interface vty04authentication-mode scheme``` ###验证-使用创建的用户名和密码通过Console或Telnet/SSH登录设备,检查权限。###引用说明[^1]:在域下绑定认证、授权方案。[^2]:配置RADIUS的基本思路(但本文配置的是本地认证)。 [^3]:建议在VTY接口使用备份认证为本地,在Console口使用备份认证为none(但本文配置为scheme,即使用AAA方案)。 [^4]:创建本地用户并设置权限。§§相关问题§§1.如何配置RADIUS认证作为主认证,本地认证作为备份? 2.如何设置不同权限级别的本地用户?3.如何恢复忘记的本地管理员密码?</think>### 配置本地管理账户及AAA认证授权模板 根据华三/华为等网络设备的配置规范,以下是配置本地管理账户和AAA模板的完整步骤: #### 1. **创建本地管理账户** ```bash system-view aaa local-user admin password cipher P@ssw0rd123 # 设置加密密码 local-user admin service-type terminal ssh # 允许终端和SSH接入 local-user admin authorization-attribute user-role network-admin # 授予管理员权限 local-user admin state active # 激活账户 ``` #### 2. **配置AAA认证方案** ```bash aaa authentication-scheme LOCAL_AUTH # 创建认证方案 authentication-mode local # 指定本地认证[^4] ``` #### 3. **配置AAA授权方案** ```bash authorization-scheme LOCAL_AUTHOR # 创建授权方案 authorization-mode local # 本地授权模式[^1] ``` #### 4. **配置AAA业务方案(可选)** ```bash accounting-scheme LOCAL_ACCT # 创建计费方案(可选) accounting-mode none # 本地操作通常无需计费 ``` #### 5. **在域中绑定AAA方案** ```bash domain default_admin # 进入管理域 authentication-scheme LOCAL_AUTH # 绑定认证方案 authorization-scheme LOCAL_AUTHOR # 绑定授权方案[^1] accounting-scheme LOCAL_ACCT # 绑定计费方案(可选) ``` #### 6. **配置用户接口认证** ```bash user-interface vty 0 4 # 配置虚拟终端 authentication-mode aaa # 启用AAA认证[^3] protocol inbound ssh # 限制SSH接入 user-interface console 0 # 配置控制台 authentication-mode aaa # 启用AAA认证 ``` #### 7. **关键安全配置(重要)** ```bash aaa administrator admin service-type terminal ssh # 限制管理协议 security-level 3 # 设置安全等级 ``` ### 配置验证命令 ```bash display local-user # 查看本地用户 display aaa scheme # 检查AAA方案 display domain default_admin # 验证域绑定 ``` ### 配置注意事项 1. **密码安全**:使用`cipher`代替`simple`加密密码[^4] 2. **备份认证**:VTY接口建议配置`authentication-mode radius local`实现RADIUS+本地双认证[^3] 3. **权限隔离**:不同角色创建独立账户(如`operator`角色仅配`user-role level-1`) 4. **控制台保护**:Console口必须配置认证,避免设备物理接触风险 > 配置示例基于H3C Comware V7平台,华为/Huawei设备命令类似(需替换`aaa`为`aaa-administrator`等)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值