使用SASL/PLAIN认证

server端
1.配置broker
kafka_server_jaas.conf
内容
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret"
user_admin="admin-secret"
user_alice="alice-secret";
};

username\password是broker初始化链接其他broker的使用的;上例admin是内部broker通信使用;
user_[user]=[password]是用户链接到broker合法验证使用的
2.添加JAAS配置到JVM的配置中,文件为kafka-server-start.sh

export KAFKA_OPTS="-Djava.security.auth.login.config=/home/app/projects/kafka/config/common/kafka_server_jaas.conf"
分割下解释
-Djava.security.auth.login.config=/etc/kafka/kafka_server_jaas.conf
该参数为添加为用户认证的server端

3.添加SASL端口和SASL认证方式添加到 server.properties
listeners=SASL_PLAINTEXT://host.name:port
security.inter.broker.protocol=SASL_PLAINTEXT
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
认证权限配置
server.propert文件
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
allow.everyone.if.no.acl.found=true //对所有用户topic可见
super.users=User:Bob;User:Alice

client端
在kafka-console-producer.sh中添加
export KAFKA_OPTS="-Djava.security.auth.login.config=/home/app/projects/kafka/config/kafka_client_jaas.conf"

kafka_client_jaas.conf文件添加如下内容
KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="alice"
password="alice-secret";
};
添加配置在producer.properties或consumer.properties
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN

授权
~/projects/kafka/bin/kafk-acls.sh --authorizer-properties zookeeper.connect=localhost:2181/tkafka --add --allow-principal User:alice --operation Read --operation Write --topic T_acl-1

生产者
./projects/kafka/bin/kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic t-cal --producer.config ~/projects/kafka/config/producer.properties
消费者

kafka使用SASL_PLAINTEXT做用户认证的更多相关文章

  1. 前后端分离下用jwt做用户认证

    0 前后端分离下的用户信息认证 前端使用Vue+axios,后端使用SpringBoot+SpringSecurity. 为了解决http无状态的问题,我采用jwt(json web token)保存 ...

  2. Python使用LDAP做用户认证

    LDAP(Light Directory Access Portocol)是轻量目录访问协议,基于X.500标准,支持TCP/IP. LDAP目录以树状的层次结构来存储数据.每个目录记录都有标识名(D ...

  3. Dockerfile 构建kibana 反向代理应用做用户认证访问

    FROM centos MAINTAINER z*****ch.cn RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime & ...

  4. Nodejs之MEAN栈开发(八)---- 用户认证与会话管理详解

    用户认证与会话管理基本上是每个网站必备的一个功能.在Asp.net下做的比较多,大体的思路都是先根据用户提供的用户名和密码到数据库找到用户信息,然后校验,校验成功之后记住用户的姓名和相关信息,这个信息 ...

  5. 使用Autodesk OAuth服务在用户认证的示例

    大家知道以Autodesk 360为核心的Autodesk 云服务已经陆续发布,ReCap API.InfraWorks API和PLM 360 REST API已经开始的Pilot项目供第三方开发者 ...

  6. auth模块用户认证

    一.auth模块什么 auth模块时django自带的用户认证模块 我们在开发一个网站的时候,无可避免的需要设计实现网站的用户系统.此时我们需要实现包括用户注册.用户登录.用户认证.注销.修改密码等功 ...

  7. Django自带的用户认证auth模块

    一.介绍 基本上在任何网站上,都无可避免的需要设计实现网站的用户系统.此时我们需要实现包括用户注册.用户登录.用户认证.注销.修改密码等功能. 使用Django,我们可以不需要自己写这些功能,因为Dj ...

  8. (30)auth模块(django自带的用户认证模块)

    Auth模块是Django自带的用户认证模块: 我们在开发一个网站的时候,无可避免的需要设计实现网站的用户系统.此时我们需要实现包括用户注册.用户登录.用户认证.注销.修改密码等功能,这还真是个麻烦的 ...

  9. Django之用户认证auth模块

    一 Django中的auth模块: 我们在使用模块之前要先导入模块: from django.contrib import auth django.contrib.auth中提供了许多方法,这里主要介 ...

随机推荐

  1. 面试官问线程安全的List,看完再也不怕了!

    最近在Java技术栈知识星球里面有球友问到了线程安全的 List: 扫码查看答案或加入知识星球 栈长在之前的文章<出场率比较高的一道多线程安全面试题>里面讲过 ArrayList 的不安全 ...

  2. jemalloc内存分配原理【转】

    原文:http://www.cnblogs.com/gaoxing/p/4253833.html 内存分配是面向虚拟内存的而言的,以页为单位进行管理的,页的大小一般为4kb,当在堆里创建一个对象时(小 ...

  3. Waring:not all local change may be shown due to an error:fatal

    idea往Git上提交文件时提示 Waring:not all local change may be shown due to an error:fatal 解决方案:选择File --> s ...

  4. 【技术博客】Git Flow模型管理代码版本

    参考GIT版本管理:Git Flow模型,在此基础上加入了自己的理解,增加人员分工和相应代码,并根据本次项目的实际情况进行相应修改. 在本学期的软件工程开发过程中,我们从alpha阶段就使用了git ...

  5. error: dereferencing pointer to incomplete type

    /******************************************************************************* * error: dereferenc ...

  6. Java NIO Buffer详解

    一.ByteBuffer类型化的put与get方法 /** * ByteBuffer类型化的put与get方法 */ public class NioTest5 { public static voi ...

  7. android -------- VideoCache 视频播放(缓存视频到本地)

    先前做了一个小视频的功能,里面有播放多个视频的功能,为了效率,我加了视频缓存功能: 一方面耗费用户的流量,另一方面直接从本地播放要更流畅 网上看资料,一个视频缓存库,使用起来很方便,还不错,就分享给大 ...

  8. JSON字符串转实体对象

    JSON转实体两种方式 代码片段 ; i < dt.Rows.Count; i++) { //Json字符串 string designJson = dt.Rows[i]["Desig ...

  9. U盘无法格式化解决

    我的U盘是fat32格式的,4G以上的东西拖不进去 于是我打算格式化成NTFS的,然后悲剧了,格式化提示windows格式化不成功

  10. react 常用组件整理

    0.es6语法糖 deptList = deptnameList.filter(item => item.rel ===this.state.thUser.orgId);//返回一个新的数组对象 ...