跳到主要內容

[HIVE] 設定 hive authorization

設定 hive authorization

root權限編輯hive config
command
vim /etc/hive/conf.dist/hive-site.xml

*需打包jar com.qiku.custom.auth.HiveServer2Auth 



<property>
          <name>hive.server2.enable.doAs</name>
          <value>false</value>
</property>
<property>
          <name>hive.server2.authentication</name>
          <value>CUSTOM</value>
</property>
<property>
          <name>hive.server2.custom.authentication.class</name>
          <value>org.apache.hive.service.auth.PasswdAuthenticationProvider.SampleAuth</value>
</property>



自定義登入邏輯

[java] 儲存為HiveServer2Auth.jar 放在${HIVE_HOME}/lib下 


package org.apache.hive.service.auth.PasswdAuthenticationProvider.SampleAuth;

import java.util.Hashtable;
import javax.security.sasl.AuthenticationException;
import org.apache.hive.service.auth.PasswdAuthenticationProvider;

/*
 javac -cp $HIVE_HOME/lib/hive-service-0.12.0-cdh5.0.0-beta-2.jar SampleAuthenticator.java -d .
 jar cf sampleauth.jar hive
 cp sampleauth.jar $HIVE_HOME/lib/.
*/


public class SampleAuthenticator implements PasswdAuthenticationProvider {

  Hashtable<String, String> store = null;

  public SampleAuthenticator () {
    store = new Hashtable<String, String>();
    store.put("user1", "passwd1");
    store.put("user2", "passwd2");
  }

  @Override
  public void Authenticate(String user, String  password)
      throws AuthenticationException {

    String storedPasswd = store.get(user);

    if (storedPasswd != null && storedPasswd.equals(password))
      return;

    throw new AuthenticationException("SampleAuthenticator: Error validating user");
  }

}


相關參考

Simple User/Password authentication for HiveServer2


[一起学Hive]之二十-自定义HiveServer2的用户安全认证

http://zhangxiong0301.iteye.com/blog/2220530

[Apache Hive] Configuration Properties


[Apache Hive] LanguageManual Authorization

留言

這個網誌中的熱門文章

[python] python 時區轉換 ( timezone )

python 時區轉換 import datetime as dt import pytz d = dt.datetime(2019,1,1,14,0,0) #create Taipei timezone tw = pytz.timezone('Asia/Taipei') #set d timezone is 'Asia/Taipei' twdt = tw.localize(d) #change to utc time utc_dt = twdt.astimezone(pytz.utc) *注意 網路上很多使用 d.replace(tzinfo=tw)   但是可能會出現時差問題, 如下: datetime.time(23, 18, 5, tzinfo=<DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>) 參考文件 python时区设置——pytz模块

[HTML] 文字浮水印效果 text watermark css

[.css] .info-mask {     height: 0;       position: absolute;       margin-top:120px;   } .info-opacity {     opacity: 0.8;     color: black; } .info-text {     color: gray;     font-size: 40px;     -webkit-transform: rotate(-5deg);       line-height: 60px;     max-width:1200px;     letter-spacing:3px;     padding-left:0.8em; } [.html]     <div class="info-mask">         <p class="info-text">             WaterMarkText         </p>     </div>    <table class="table table-bordered table-striped table-responsive table-hover" style="position:                 relative;" >        <tbody class="info-opacity" >        </tbody>    </table>

[Linux] 解決 unix ///tmp/supervisor.sock no such file

supercisor run  一段時間系統會自動刪除tmp內的檔案, 這時候就會出現以下問題: unix ///tmp/supervisor.sock no such file 作業環境: Centos 7 *解決方法 修改 supervisor 設定檔 [...]#  vim /etc/supervisor/supervisord.conf [unix_http_server] file= /var/run/ supervisor.sock  ... [supervisord] logfile= /var/log/ supervisord.log ... [supervisorctl] serverurl=unix:/// var/run/ supervisor.sock 重新執行supervisor  關閉supervisor相關進程 [...]#  ps -ef | grep supervisord   [...]#  kill (進程id) 重新執行supervisor [...]# supervisord or [...]# supervisord -c /etc/supervisor/supervisord.conf 參考連結 解决unix:///tmp/supervisor.sock no such file的问题