前言
Kafka kerberos 认证一般分为动态认证和静态认证:
动态认证即通过在properties配置项中sasl.jaas.config认证字符串来进行,静态认证通过System.setProperty(“java.security.auth.login.config”,"")来进行,如果在同一个jvm中需要进行不同服务的kerberos认证连接时 使用kafka静态认证方式,会产生奇奇怪怪的问题,例如真实的认证用户不是当前请求传递的用户或者命名传了正确的kerberos认证信息,但是却认证失败:Could not find a ‘kafkaClient’ entry in the JAAS configuration. System property ‘java.security.auth.login.config’ is /xxxxx/xxxxx/xxxxxx_jaas.conf。
一、Kafka的认证流程源码解读
上源码 KafkaConsumer的kerberos认证在的构造方法的
ChannelBuilder channelBuilder = ClientUtils.createChannelBuilder(config, time);
 
这一行,进去
 
 进入之后如下:
 
 因此在kafka的properties中加加入下面这个配置项
properties.put("security.protocol","SASL_PLAINTEXT")
 
进入create方法:
 
 继续进入JassContext.loadClientContext方法:
 
public static JaasContext loadClientContext(Map<String, ?> configs) {
   
   
        String globalContextName = GLOBAL_CONTEXT_NAME_CLIENT;
        Password dynamicJaasConfig = (
                
                  
                  
                  
                  
本文详细解析了Kafka中的Kerberos认证过程,包括动态认证与静态认证的区别及实现方式,并提供了具体的代码示例。同时探讨了在多数据源共存环境下如何选择合适的认证方式。
          
最低0.47元/天 解锁文章
                          
                      
      
          
                
                
                
                
              
                
                
                
                
                
              
                
                
              
            
                  
					999
					
被折叠的  条评论
		 为什么被折叠?
		 
		 
		
    
  
    
  
            


            