cloudera / impyla

Python DB API 2.0 client for Impala and Hive (HiveServer2 protocol)
Apache License 2.0
731 stars 248 forks source link

Allow passing a JWT into connect via an environment variable #474

Open joemcdonnell opened 3 years ago

joemcdonnell commented 3 years ago

Impyla recently added support for authenticating via a JWT bearer token passed in at connect time.

It would be useful to support some additional ways to pass in a JWT. For example, a user could specify the JWT via an environment variable or an environment variable that specifies a file containing the JWT. This could allow python programs to execute in a particular environment without having to specifying anything other than auth_mechanism=JWT.

One option is to add a parameter to connect() that specifies the environment variable that is a file containing the JWT (with a default value like "IMPYLA_JWT_FILE").

If the user specifies auth_mechanism=JWT, then the JWT value is determined by this preference order: If the explicit jwt parameter on connect is set, use it else if the environment has a value for the jwt file environment variable, read the file and use it else give an error.

yoderme commented 3 years ago

I think that if auth_mechanism=JWT it's fine for us to dictate the name of the environment variable. However the name of this environment variable MUST be the same as what hive JDBC drivers use.