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

Shard long JWT token on Windows #477

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

hovaesco
Copy link
Member

Description

Currently, storing a long JWT token on Windows triggers the following error:

During handling of the above exception, another exception occurred:
....
  File "\lib\site-packages\trino\auth.py", line 403, in _authenticate
    self._attempt_oauth(response, **kwargs)
  File "\lib\site-packages\trino\auth.py", line 449, in _attempt_oauth
    self._store_token_to_cache(key, token)
  File "\lib\site-packages\trino\auth.py", line 498, in _store_token_to_cache
    self._token_cache.store_token_to_cache(key, token)
  File "\lib\site-packages\trino\auth.py", line 360, in store_token_to_cache
_password
    get_keyring().set_password(service_name, username, password)
  File "\lib\site-packages\keyring\backends\Windows.py", line 128, in set_password
    self._set_password(service, username, str(password))
  File "\lib\site-packages\keyring\backends\Windows.py", line 139, in _set_password
    win32cred.CredWrite(credential, 0)
  File "\lib\site-packages\win32ctypes\pywin32\win32cred.py", line 35, in CredWrite
    _authentication._CredWrite(c_pcreds, 0)
  File "\lib\contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "\lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
    raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (1783, 'CredWrite', 'The stub received bad data')

This pull request addresses the issue by introducing sharding for long JWT tokens on Windows, ensuring they are stored correctly without causing the above error.

Based on databricks/dbt-databricks#599

Non-technical explanation

Release notes

( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text:

* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label Aug 13, 2024
tests/unit/test_client.py Outdated Show resolved Hide resolved
@hovaesco hovaesco force-pushed the hovaesco/keyring-long-pass branch 2 times, most recently from 20c655a to bc557e4 Compare August 14, 2024 14:42
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@hashhar hashhar merged commit 560556b into trinodb:master Aug 27, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants