Token based authentication (JWT) in knox for hive jdbc

1.1k Views Asked by At

I have set token based authentication in apache knox. I am able to generate token using the following command :

curl -ivku guest:guest-password https://localhost:8443/gateway/sandbox/knoxtoken/api/v1/token

Using the token, I am authenticating in a curl command like this :

curl -ivk -H "Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJndWVzdCIsImF1ZCI6InRva2VuYmFzZWQiLCJpc3MiOiJLTk9YU1NPIiwiZXhwIjoxNDg5OTQyMTg4fQ.bcqSK7zMnABEM_HVsm3oWNDrQ_ei7PcMI4AtZEERY9LaPo9dzugOg3PA5JH2BRF-lXM3tuEYuZPaZVf8PenzjtBbuQsCg9VVImuu2r1YNVJlcTQ7OV-eW50L6OTI0uZfyrFwX6C7jVhf7d7YR1NNxs4eVbXpS1TZ5fDIRSfU3MU" https://localhost:8443/gateway/tokenbased/webhdfs/v1/tmp?op=LISTSTATUS

But I want to authenticate a hive jdbc connection. How can I add this token in a hive jdbc url. My jdbc url is :

jdbc:hive2://localhost:8443/;ssl=true;sslTrustStore={path to gateway.jks};trustStorePassword={master-secret key};transportMode=http;httpPath=gateway/{cluster-name}/hive
1

There are 1 best solutions below

0
On

You should be able to pass the http cookie with JWT token through JDBC, something like jdbc:hive2://knox_host:knox_port;transportMode=http;httpPath=<http_endpoint>;http.cookie.<cookie_name>=<cookie_value>

Default cookie name is 'http.cookie.hadoop-jwt'