trinodb / trino-python-client

Python client for Trino
Apache License 2.0
311 stars 154 forks source link

Support custom cache for OAuth2 tokens #225

Open mdesmet opened 1 year ago

mdesmet commented 1 year ago

Fixes #223

hashhar commented 1 year ago

I'd prefer if we made the defaults more useful instead of adding hooks for custom behaviour and leaving users to implement them themselves.

It seems default should be to cache based on identity (which is what Trino itself seems to do).

mdesmet commented 1 year ago

I'd prefer if we made the defaults more useful instead of adding hooks for custom behaviour and leaving users to implement them themselves.

That won't work in a distributed web application. You would need to store and retrieve the tokens in a distributed cache (eg redis) as every request may be handled by different nodes.

It seems default should be to cache based on identity (which is what Trino itself seems to do).

This is not entirely true. The user is not required in the connect(args) for OAuth connections. Without the user we would only be able to retrieve the identity by running a SELECT CURRENT_USER() query.