Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAIN auth with http transport fails producing valid BASIC auth header for long username/password combinations #540

Open
paulmayer opened this issue May 7, 2024 · 1 comment

Comments

@paulmayer
Copy link

paulmayer commented May 7, 2024

Impyla version: v0.18.0
Python version: 3.10.9

Minimal Example:

from impala.dbapi import connect

con = connect(
    "https://my-impala-host",
    auth_mechanism="PLAIN",
    use_http_transport=True,
    user="foo",
    password="this-is-a-very-long-password-that-is-really-very-long-and-goes-even-longer",
)

con.cursor()

Produces ValueError: Invalid header value b'Basic Zm9vOnRoaXMtaXMtYS12ZXJ5LWxvbmctcGFzc3dvcmQtdGhhdC1pcy1yZWFsbHktdmVyeS1sb25n\nLWFuZC1nb2VzLWV2ZW4tbG9uZ2Vy'

Expected Behavior:

Long password and user tuples are gracefully handled, either by setting limits or by robustly producing Basic auth headers also for long user/password combinations

Where is this problem coming from?

base64.encodebytes inserts newlines after every 76 bytes of output. These would need to be filtered out here

Alternatively, use base64.b64encode

@uniqueinput
Copy link

Hi,
we also face this issue with impyla 0.19 and CDW Public Cloud.
Not sure though whether a special character or the length of the password is causing this.
A more safer way would probably be to use
https://docs.python.org/3/library/base64.html#base64.urlsafe_b64encode

instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants