webtau icon indicating copy to clipboard operation
webtau copied to clipboard

Implement a caching auth provider

Open tsiq-karold opened this issue 7 years ago • 3 comments

We have a couple of auth provider implementations now which basically do the same thing when asked for a token:

  • check local cache file and its validity (in terms of time expiry)
  • if valid, great
  • if not valid, fetch new token and cache it

Would be nice for webtau to have some sort of helper class/utils to make this easier and reduce the duplication.

tsiq-karold avatar Sep 19 '18 15:09 tsiq-karold

Sounds like a good idea. On the other hand webtau doesn't know anything about auth at the moment. It has header provider and navigation page open handlers.

tsiq-nick avatar Sep 19 '18 15:09 tsiq-nick

True, may require a bit of refactoring or building an auth specific helper but something like CachingHeaderProvider might work; the auth header could as easily be cached as the auth token.

tsiq-karold avatar Sep 19 '18 15:09 tsiq-karold

it will work for http header with a decorator. Will not help with page browser open handler as it has imperative logic, not declarative.

tsiq-nick avatar Sep 19 '18 15:09 tsiq-nick