Python 使用thrift api连接安全配置单元
我正在尝试将secure Hive server与Python 使用thrift api连接安全配置单元,python,hive,thrift,Python,Hive,Thrift,我正在尝试将secure Hive server与thriftapi连接。如果HiveServer不需要身份验证(不安全),但不适用于安全的HiveServer,则此代码可以正常工作 参考文献 您需要在代码中添加身份验证机制,如“nosal”、“KERBEROS”、“LDAP”等,并根据这一点,您必须提供适当的凭据 例如: authMechanisms = set(['NOSASL', 'PLAIN', 'KERBEROS', 'LDAP']) if authMechanism not
thrift
api连接。如果HiveServer不需要身份验证(不安全),但不适用于安全的HiveServer,则此代码可以正常工作
参考文献
您需要在代码中添加身份验证机制,如“nosal”、“KERBEROS”、“LDAP”等,并根据这一点,您必须提供适当的凭据 例如:
authMechanisms = set(['NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'])
if authMechanism not in authMechanisms:
raise NotImplementedError('authMechanism is either not supported or not implemented')
#Must set a password for thrift, even if it doesn't need one
#Open issue with python-sasl
if authMechanism == 'PLAIN' and (password is None or len(password) == 0):
password = 'password'
socket = TSocket(host, port)
socket.setTimeout(timeout)
if authMechanism == 'NOSASL':
transport = TBufferedTransport(socket)
else:
sasl_mech = 'PLAIN'
saslc = sasl.Client()
saslc.setAttr("username", user)
saslc.setAttr("password", password)
if authMechanism == 'KERBEROS':
krb_host,krb_service = self._get_krb_settings(host, configuration)
sasl_mech = 'GSSAPI'
saslc.setAttr("host", krb_host)
saslc.setAttr("service", krb_service)
参考:您需要在代码中添加身份验证机制,如“nosal”、“KERBEROS”、“LDAP”等,并根据该机制提供适当的凭据 例如:
authMechanisms = set(['NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'])
if authMechanism not in authMechanisms:
raise NotImplementedError('authMechanism is either not supported or not implemented')
#Must set a password for thrift, even if it doesn't need one
#Open issue with python-sasl
if authMechanism == 'PLAIN' and (password is None or len(password) == 0):
password = 'password'
socket = TSocket(host, port)
socket.setTimeout(timeout)
if authMechanism == 'NOSASL':
transport = TBufferedTransport(socket)
else:
sasl_mech = 'PLAIN'
saslc = sasl.Client()
saslc.setAttr("username", user)
saslc.setAttr("password", password)
if authMechanism == 'KERBEROS':
krb_host,krb_service = self._get_krb_settings(host, configuration)
sasl_mech = 'GSSAPI'
saslc.setAttr("host", krb_host)
saslc.setAttr("service", krb_service)
<> >:< /p>什么是<代码> C++ >代码>这部分不是语言基础问题,我可以接受任何语言的答案,无论如何我已经删除C++什么是<代码> C++ >代码>这部分?它不是语言基础问题,我可以接受任何语言的答案,无论如何我已经删除了C++。