2013-08-12 17 views
6

HiveServer2の単純なプロパティファイルまたはデータベースユーザー/パスワード認証を提供する方法は?HiveServer2(Kerberos/LDAPなし)の単純なユーザー/パスワード認証

私はすでにこのことについてthisプレゼンテーションを見つけましたが、それは英語:(ではありません。彼らはhive.server2.authentication財産について話Cloudera reference manualで 。それはインターフェースhive.server2.custom.authenticationCUSTOM実装をサポートしています。

それを実装する方法は?

答えて

10

本質的には、認証を実行できるjavaアプリケーションを用意する必要があります.MySQLやPostgresデータベース、またはフラットファイルなどにauthingしているかもしれません。orgを実装できるjarを提供する必要があります。 apache.hive.service.auth.PasswdAuthenticationProvider interfa ce。

簡単な例:

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"); 
    } 

} 

そしてハイブ-site.xml内、新しく作成したカスタム認証の瓶を使用します。

<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> 
関連する問題