Hadoop delegation token authentication
- Last Updated: April 19, 2022
- 2 minute read
- DataDirect Connectors
- JDBC
- Apache Hive 6.0
- Documentation
In Hadoop clusters, delegation tokens are a lightweight authentication solution that allow connections the benefits of Kerberos authentication without requiring constant contact with the Kerberos Key Distribution Center (KDC) for user ticket validations and service ticket requests. For delegation token authentication, a single connection authenticates to the KDC and retrieves the delegation token from the server. That delegation token can then be shared among other connection to authenticate user requests without requiring additional requests to the KDC.
To use Hadoop delegation token authentication, you must modify your connection code to perform the following:
- Connect using Kerberos authentication with a keytab or ticket cache. For
example:
Connection kerbCon = DriverManager.getConnection ("jdbc:datadirect:hive://myHiveHost:10000;databaseName=myHiveDB; AuthenticationMethod=kerberos;ServicePrincipalName=hive/myHiveHost@MY.KERB.DOMAIN.COM");See "Configuring the driver for Keberos authentication" for an overview of standard Kerberos authentication.
- Cast the connection to the DataDirect ExtDelegationTokenConnection class.
Then call the method to get the token string from the driver and store it in your
application. For example:
where:String token = (com.ddtek.jdbc.extensions.ExtDelegationTokenConnection)kerbCon.getDelegationToken ("<owner>", "<renewer_name>");- owner
- is the owner who supplied the Kerberos ticket at
connection. For example, if you executed the kinit command with
myUser@myDomain.com, this value would bemyUser. - renewer_name
- is the user that makes the renewDelegationToken call, if you want to use renewable tokens. However, if you do not want to renew tokens, then this string can any be any other value. In this scenario, the token can still be used for authentication, but it will not be renewable.
- Connect using a new connection string that specifies:
- Using the AuthenticationMethod property, the
DelegationTokenvalue. - Using the SASLQOP property, the quality of protection used on the server for
SASL mechanisms. The default is
auth. - Using the DelegationToken property, the delegation token value.
Connection tokenCon = DriverManager.getConnection ("jdbc:datadirect:hive://myHiveHost:10000;DatabaseName=myHiveDB; AuthenticationMethod=delegationToken;SASLQOP=auth-conf;DelegationToken=" + token); - Using the AuthenticationMethod property, the
- To renew tokens, call the renewDelegationToken method on the connection that
originally authenticated to Kerberos. For
example:
((com.ddtek.jdbc.extensions.ExtDelegationTokenConnection)con).renewDelegationToken(token); - To cancel tokens, call the cancelDelegationToken method on the connection
that originally authenticated to Kerberos. For example:
((com.ddtek.jdbc.extensions.ExtDelegationTokenConnection)con).cancelDelegationToken(token);