ranger kafka

摘要:
No,onecan’tuseuser/groupbasedaccesstoauthorizeKafkaaccessoveranon-securechannel.Thisisbecauseitisn'tpossibletoassertclient’sidentityoverthenon-securechannel.Whatisarecommendedwaytoset-uppolicieswhentryingtocontrolaccesstoKafkaoveranon-securechannel?EnsurethatallBrokersnodeshaveKafkaAdminaccess.Thisisamandatorystep.Ifyoudon’tperformthisstepthenyourclusterwon’tworkproperly.Identifythenodeswherebrokersarerunning.Createapolicywhereresourceis*(i.e.alltopics)andgrantKafkaAdminaccesstypetothepublicusergroup.Specifyip-addressofallthebrokersastheip-rangepolicyconditiononthepolicyitem.Ensurepublishershaveappropriateaccess.Identifyipaddressofallnodeswherepublisherswouldrunalongwiththeirrespectivetopics.CreatepolicywhereresourcesaretherespectivetopicnamesandgrantPublishaccesstypetopublicusergroup.Specifyip-addressofmachineswherethosepublisherswouldrunastheip-rangepolicyconditiononthepolicyitem.Specifytopicname(s)aspolicyresource.Notethatyoucanspecifymultipletopicsorevenregularexpressionsintopicnames.Ensureconsumershaveappropriateaccess.SameprocessaspublishersexceptchangeaccesstypetoConsumeinsteadorProduce.WhydowehavetospecifypublicusergrouponallpoliciesitemscreatedforauthorizingKafkaaccessovernon-securechannel?Kafkacan’tasserttheidentityofclientuseroveranon-securechannel.Thus,Kafkatreatsallusersforsuchaccessasananonymoususer(aspecialuserliterallynamedANONYMOUS).Ranger'spublicusergroupisameanstomodelalluserswhich,ofcourse,includesthisanonymoususer(ANONYMOUS).WhatarethespecificthingstowatchoutforwhensettingupauthorizationforaccessingKafkaovernon-securechannel?Makesurethatallbroker-ipshaveKafkaadminaccesstoalltopics,i.e.*.Makesurenopublishersorconsumersarerunningonbrokernodesthatneedaccesscontrol.Sincebrokeripshaveopenaccessitisn’tpossibletocontrolaccessonthosenodes.Ihavethepoliciesasspecifiedabove,however,Iamstillnotabletoconsumeoverannon-authenticatedchannelusingbin/kafka-console-consumer.shscriptthatisapartoftheKafkadistribution!Theconsumerhangsandgivestheerrormessage“NobrokersfoundinZK.”Whatgives?Ensurethat/etc/kafka/conf/kafka_client_jaas.confdoesnothavespecificationforserviceName="zookeeper".ThisistypicallytheClientsection.Ensurethatyouarenotspecifying--security-protocolPLAINTEXTSASLargumenttotheconsumer.Eitherspecify--security-protocolPLAINTEXTorleave--security-protocolunspecifiedsinceitsdefaultvalueisPLAINTEXT.Ican’teditthe/etc/kafka/conf/kafka_client_jaas.conffile!

Authorizing Kafka access over non-authenticated channel via Ranger

This section answers some questions one is likely to encounter when trying to authorize access to Kafka over non-authenticated channel. This Kafka feature is available in HDP releases 2.3.4 (Dal-M20) or later.

Can I authorizer access to Kafka over a non-secure channel via Ranger?

Yes. you can control access by ip-address.

Can I authorize access to Kafka over non-secure channel by user/user-groups?

No, one can’t use user/group based access to authorize Kafka access over a non-secure channel. This is because it isn't possible to assert client’s identity over the non-secure channel.

What is a recommended way to set-up policies when trying to control access to Kafka over a non-secure channel?

Ensure that all Brokers nodes haveKafka Adminaccess. This is a mandatory step. If you don’t perform this step then your cluster won’t work properly.

  • Identify the nodes where brokers are running.

  • Create a policy where resource is*(i.e. all topics) and grantKafka Adminaccess type to thepublicuser group. Specify ip-address of all the brokers as theip-range policy conditionon the policy item.

Screen Shot 2015-12-10 at 6.41.01 PM.png

Ensure publishers have appropriate access.

  • Identify ip address of all nodes where publishers would run along with their respective topics.

  • Create policy where resources are the respective topic names and grantPublishaccess type topublicuser group. Specify ip-address of machines where those publishers would run as theip-range policy conditionon the policy item.

  • Specify topic name(s) as policy resource. Note that you can specify multiple topics or even regular expressions in topic names.

Screen Shot 2015-12-10 at 6.44.11 PM.png

Ensure consumers have appropriate access. Same process as publishers except change access type toConsumeinstead orProduce.

Screen Shot 2015-12-10 at 6.45.24 PM.png

Why do we have to specifypublicuser group on all policies items created for authorizing Kafka access over non-secure channel?

  • Kafka can’t assert the identity of client user over a non-secure channel. Thus, Kafka treats all users for such access as an anonymous user (a special user literally namedANONYMOUS).

  • Ranger'spublicuser group is a means to model all users which, of course, includes this anonymous user (ANONYMOUS).

What are the specific things to watch out for when setting up authorization for accessing Kafka over non-secure channel?

  • Make sure that all broker-ips haveKafka adminaccess to all topics, i.e.*.
  • Make sure no publishers or consumers are running on broker nodesthat need access control. Since broker ips have open access it isn’t possible to control access on those nodes.

I have the policies as specified above, however, I am still not able to consume over an non-authenticated channel usingbin/kafka-console-consumer.shscript that is a part of the Kafka distribution! The consumer hangs and gives the error message “No brokers found in ZK.” What gives?

  • Ensure that/etc/kafka/conf/kafka_client_jaas.confdoes not have specification forserviceName="zookeeper". This is typically theClientsection.
  • Ensure that you are not specifying--security-protocol PLAINTEXTSASLargument to the consumer. Either specify--security-protocol PLAINTEXTor leave--security-protocolunspecified since its default value isPLAINTEXT.

I can’t edit the/etc/kafka/conf/kafka_client_jaas.conffile! What should I do to consume kafka messages over an non-authenticated channel?

  • In that case just do akinitwith a valid password/ticket.
  • That token will get used to authenticate you tozookeeper. After that you should be able to consume messages from kafka over non-authenticated channel. Connection to Kafka brokers correctly happens over non-authenticated channel and should get authorized as userANONYMOUS.

Why do I need to edit the/etc/kafka/conf/kafka_client_jaas.conffile?

Presence ofClientblock in/etc/kafka/conf/kafka_client_jaas.conffor servicezookeepercauses the console consumer connect to zookeeper in secure mode. To do so it needs a ticket -- which won’t exist in simple auth mode, so it fails.

Authorizing topic creation

This section describes the issues one might encounter while trying to authorize topic creation in Kafka using Ranger.

Can I authorizer topic creation via Ranger?

Yes, butonlyifthe topic is beingauto-createdby consumers or producers.

What is the recommended policy setup to authorize topic auto-creation for producers or consumers?

  • Create a policy where resource is all topics, i.e.*.
  • For producers, create a policy item under this policy which grants bothProduceandConfigurepermissions to the relevant user/user-groups.

  • For consumers, create a policy item under this policy which grants bothConsumeandConfigurepermissions to the relevant user/user-groups.

Can I authorize topic auto-creation for producers or consumers that connect over non-authenticated channel?

  • Yes, create a policy similar to that for secure producer.
  • Either add user grouppublicto the policy item or specify andip-addressbase custom condition.
  • Refer to FAQ about authorizing Kafka access over non-authenticated channel for additional details and rationale.

Why do I have to grant create access to all topics (via*) to allow for auto-creation to work for producers and/or consumers?

Topic creation is currently a cluster level privilege. Thus it requires access privileges over all topics in a cluster, i.e.*.

I want to allow topic auto creation for any topic that starts withfinance, e.g.finance_1,finance_2, etc. to users that are part ofFinanceuser group. But I don’t want them to be able to auto create topics that start with other strings, say,marketing_123. Can I model this sort of an authorization in Ranger Kafka plugin?

  • No. Because in Kafka currently topic creation is a cluster level permissions, i.e. all topics.
  • There is a pending proposal aboutHierarchical topicsin Kafka which, if and when it’s implemented, could help with that use case.

I am using the Kafka supplied console consumer to test topic auto creation by a consumer, but it is not working. Shouldn’t the new topic get auto-created the moment I startup the consumer? I have verified the recommended policy setup as indicated above! What gives?

Make sure that you specify the following two argument to the console consumer.

  • --new-consumer
  • --boot-strap <broker-name(s)>: Any single broker host/port would do.

Most common way of creating topic involves using thebin/kafka-tpics.shscript that is a part of the Kafka distribution. Can I authorize topic creation via that mechanism?

No.

Why can’t I authorize topic creation done via thebin/kafka-tpics.shscript!?

  • This script talks directly to zookeeper. Hence, the policies of Kafka plugin don’t come into the picture.
  • Script adds entries into zookeeper nodes and watchers inside the brokers monitor it and create topics.

So what are my options to authorize topic creation via thebin/kafka-tpics.shscript?

  • Since this directly interacts with zookeeper this is best controlled via zookeeper acls.

Is there a Ranger plugin for Zookeeper?

Not yet.

Where can I learn more about Kafka’s support for publish/consume over non-authenticated channel?

Please refer toKAFKA-1809which implemented themultiple listeners Design.

免责声明:文章转载自《ranger kafka》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Mybatis的基本操作案列增加以及源码的分析(二)mysql8 安装配置教程下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

KAFKA架构原理

基础架构及术语   话不多说,先看图,通过这张图我们来捋一捋相关的概念及之间的关系:      如果看到这张图你很懵逼,木有关系!我们先来分析相关概念 Producer:Producer即生产者,消息的产生者,是消息的入口。  kafka cluster:    Broker:Broker是kafka实例,每个服务器上有一个或多个kafka的实例,我们姑且...

第18章-使用WebSocket和STOMP实现消息功能

Spring 4.0为WebSocket通信提供了支持,包括: 发送和接收消息的低层级API; 发送和接收消息的高级API; 用来发送消息的模板; 支持SockJS,用来解决浏览器端、服务器以及代理不支持WebSocket的问题。 1 使用Spring的低层级WebSocket API 按照其最简单的形式,WebSocket只是两个应用之间通信的通道。...

RocketMQ消息至少一次(At least Once)投递和消费

至少一次(At least Once)指每个消息必须投递一次。Consumer先Pull消息到本地,消费完成后,才向服务器返回ack,如果没有消费一定不会ack消息,所以RocketMQ可以很好的支持此特性。 生产者 在同步非顺序投递的时候,每次都是轮询到不同的队列: Message message = new Message("topic...

zookeeper + kafka集群安装部署文档

  部署环境 服务 所属ip和占用的端口 zookeeper 192.169.1.71:2181 kafka1 192.169.1.71:9092 kafka2 192.169.1.70:9092 kafka3 192.169.1.21:9092   搭建zookeeper + kafka前需要安装jdk,jdk需1.8及以上 一、...

c#使用access数据库时 模糊查询 like 通配符的写法

access通配符为*和? sqlserver通配符为%和_ 在access中使用sql查询语句,进行模糊查询要用:select * from table where name like '*海*' 而在c#中调用该语句却得不到结果,解决办法是c#中使用下面语句:select * from table where name like '%%海%%'...

ACCESS_REFUSED

问题描述:FatalListenerStartupException: Authentication failure 问题原因:连接RabbitMQ服务器异常,要么是用户名和密码错误,要么是使用的用户名没有权限登录,比如用guest用户 问题解决: 1、使用正确的用户名和密码 2、重新创建一个用户名和密码 网络上的解决方案: https://www.rab...