cxzl25 commented on code in PR #7182: URL: https://github.com/apache/kyuubi/pull/7182#discussion_r2316068495
########## kyuubi-server/src/main/scala/org/apache/kyuubi/credentials/HBaseDelegationTokenProvider.scala: ########## @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kyuubi.credentials + +import org.apache.hadoop.conf.Configuration +import org.apache.hadoop.hbase.client.ConnectionFactory +import org.apache.hadoop.hbase.security.token.ClientTokenUtil +import org.apache.hadoop.security.Credentials + +import org.apache.kyuubi.{KyuubiException, Logging} +import org.apache.kyuubi.config.KyuubiConf +import org.apache.kyuubi.credentials.HadoopFsDelegationTokenProvider.doAsProxyUser + +private class HBaseDelegationTokenProvider + extends HadoopDelegationTokenProvider with Logging { + + override def serviceName: String = "hbase" + private var tokenRequired: Boolean = _ + private var hbaseConf: Configuration = _ + private var kyuubiConf: KyuubiConf = _ + + override def initialize(hadoopConf: Configuration, kyuubiConf: KyuubiConf): Unit = { + this.kyuubiConf = kyuubiConf + this.hbaseConf = hadoopConf + this.tokenRequired = hbaseConf.get("hbase.security.authentication") == "kerberos" + } + + override def obtainDelegationTokens( + owner: String, + creds: Credentials): Unit = { + doAsProxyUser(owner) { + try { + info(s"Getting hbase token for ${owner} ...") + val conn = ConnectionFactory.createConnection(hbaseConf) Review Comment: If we use reflection to obtain tokens similar to Spark, this will avoid direct introduction of dependencies. https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/deploy/security/HBaseDelegationTokenProvider.scala#L45-L54 -- 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. To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org For additional commands, e-mail: notifications-h...@kyuubi.apache.org