2013-08-12 17 views
6

W jaki sposób udostępnić HiveServer2 proste uwierzytelnianie pliku właściwości lub bazy danych użytkownika/hasła?Proste uwierzytelnianie użytkownika/hasła dla HiveServer2 (bez protokołu Kerberos/LDAP)

Znalazłem już this prezentację na ten temat, ale nie jest w języku angielskim :(. Na Cloudera reference manual Mówią o własności hive.server2.authentication. Obsługuje CUSTOM implementacje interfejsu hive.server2.custom.authentication.

Jak wdrożyć to?

Odpowiedz

10

Zasadniczo musisz dostarczyć aplikację java, która może wykonać twoje uwierzytelnienie. Może masz uprawnienia do bazy danych mysql lub postgres, lub pliku płaskiego itp. Musisz podać słoik, który może zaimplementować org. apache.hive.service.auth.PasswdAuthenticationProvider interfa ce.

Prosty przykład:

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

} 

A potem w ula-site.xml, korzystać z nowo utworzonego słoik uwierzytelniania niestandardowe:

<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> 
Powiązane problemy