refactor(FIR-46254): merge token and url caching#454
Conversation
|
|
| def _token_storage(self) -> Optional[TokenSecureStorage]: | ||
| """Token filesystem cache storage. | ||
| def _get_cached_token(self) -> Tuple[Optional[str], Optional[int]]: | ||
| """If caching is enabled, get token from cache. |
There was a problem hiding this comment.
I am guessing we also return the validity of the token? What is the tuple return needed for
There was a problem hiding this comment.
yeah, token and its expiry - https://github.com/firebolt-db/firebolt-python-sdk/pull/454/files/88129aad4541917b102da74bf38f55ed6ff8f863#diff-ffbb4e973c25af4ceb5128e7cf8885e1c6c4df4949113a1e500bc8712f2ff525R140
Docstring needs to be updated.
3446035 to
436a240
Compare
|
Created merge_caching_bkp in case some merge conflicts were not resolved correctly. |
|



This pull request introduces a significant refactor of the token caching mechanism for authentication in the Firebolt Python SDK. The main changes involve replacing the previous filesystem-based token cache with a new, encrypted, file-based cache system, updating the
Authclasses to use this new cache, and removing legacy token storage code. The update also ensures that account names are consistently set in authentication objects during connection setup.Token caching and storage refactor:
FileBasedCacheclass insrc/firebolt/utils/cache.pythat provides encrypted, persistent, file-based caching for authentication tokens and connection info, replacing the oldTokenSecureStoragesystem. This includes logic for OS-specific cache directories, encryption, and expiry handling.Authclass insrc/firebolt/client/auth/base.pyto use the new_firebolt_cachefor token retrieval and storage, including adding anaccountproperty to ensure tokens are cached per-account.TokenSecureStorageand related code from the authentication classes (UsernamePassword,ServiceAccount,ClientCredentials), and deleted the compatibility import insrc/firebolt/common/token_storage.py.Connection setup improvements:
account_nameis consistently assigned to theauthobject in both async and syncconnectfunctions, which is necessary for correct token caching and retrieval.Data structure enhancements:
ConnectionInfodataclass to include atokenfield and a__post_init__method for robust deserialization of nested dataclasses from cache.