chengshiwen commented on issue #4089:
URL: 
https://github.com/apache/incubator-dolphinscheduler/issues/4089#issuecomment-817110997


   The following is the community reply:
   
   java 的kerberos是标准化,和curator没有关系。 启动参数增加jaas配置就行了
   
   找了段hbase的zk建立 secure 连接的
   ```
   // login the zookeeper server principal (if using security)
         ZKUtils.loginServer(conf, "hbase.zookeeper.server.keytab.file",
           "hbase.zookeeper.server.kerberos.principal",
           zkConfig.getClientPortAddress().getHostName());
   
   ```
   ```
   /**
      * Log in the current zookeeper server process using the given 
configuration
      * keys for the credential file and login principal.
      *
      * <p><strong>This is only applicable when running on secure hbase</strong>
      * On regular HBase (without security features), this will safely be 
ignored.
      * </p >
      *
      * @param conf The configuration data to use
      * @param keytabFileKey Property key used to configure the path to the 
credential file
      * @param userNameKey Property key used to configure the login principal
      * @param hostname Current hostname to use in any credentials
      * @throws IOException underlying exception from SecurityUtil.login() call
      */
     public static void loginServer(Configuration conf, String keytabFileKey,
         String userNameKey, String hostname) throws IOException {
       login(conf, keytabFileKey, userNameKey, hostname,
             ZooKeeperSaslServer.LOGIN_CONTEXT_NAME_KEY,
             JaasConfiguration.SERVER_KEYTAB_KERBEROS_CONFIG_NAME);
     }
   ```
   
   ```
   /**
      * Log in the current process using the given configuration keys for the
      * credential file and login principal.
      *
      * <p><strong>This is only applicable when running on secure hbase</strong>
      * On regular HBase (without security features), this will safely be 
ignored.
      * </p >
      *
      * @param conf The configuration data to use
      * @param keytabFileKey Property key used to configure the path to the 
credential file
      * @param userNameKey Property key used to configure the login principal
      * @param hostname Current hostname to use in any credentials
      * @param loginContextProperty property name to expose the entry name
      * @param loginContextName jaas entry name
      * @throws IOException underlying exception from SecurityUtil.login() call
      */
     private static void login(Configuration conf, String keytabFileKey,
         String userNameKey, String hostname,
         String loginContextProperty, String loginContextName)
         throws IOException {
       if (!isSecureZooKeeper(conf))
         return;
   
       // User has specified a jaas.conf, keep this one as the good one.
       // HBASE_OPTS="-Djava.security.auth.login.config=jaas.conf"
       if (System.getProperty("java.security.auth.login.config") != null)
         return;
   
       // No keytab specified, no auth
       String keytabFilename = conf.get(keytabFileKey);
       if (keytabFilename == null) {
         LOG.warn("no keytab specified for: " + keytabFileKey);
         return;
       }
   
       String principalConfig = conf.get(userNameKey, 
System.getProperty("user.name"));
       String principalName = SecurityUtil.getServerPrincipal(principalConfig, 
hostname);
   
       // Initialize the "jaas.conf" for keyTab/principal,
       // If keyTab is not specified use the Ticket Cache.
       // and set the zookeeper login context name.
       JaasConfiguration jaasConf = new JaasConfiguration(loginContextName,
           principalName, keytabFilename);
       javax.security.auth.login.Configuration.setConfiguration(jaasConf);
       System.setProperty(loginContextProperty, loginContextName);
     }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to