globus-sdk-python icon indicating copy to clipboard operation
globus-sdk-python copied to clipboard

TokenStorage (v2)

Open aaschaer opened this issue 1 year ago • 0 comments

Shortcut: https://app.shortcut.com/globus/story/33154/sdk-storageadapterv2

Change Summary (all in experimental):

  • Adds TokenStorage which expands upon StorageAdapter by adding namespace support and requires implementing classes to support remove_tokens_for_resource_server. It also allows passing token data as a dict in addition to a OAuthTokenResponse and removes on_refresh as that was only ever an alias for store
  • Adds TokenData which is a data class for tokens and metadata, notably including identity_id which is needed by ValidatingTokenStorage
  • Adds FileTokenStorage which is nearly much identical to FileAdapter beyond implementing StorageAdapterV2 instead of StorageAdapterV2
  • Adds MemoryTokenStorage which remains fairly simple.
  • Adds JSONTokenStorage which now stores data under namespaced keys and has logic for migrating storage from a SimpleJSONFileAdapter
  • Adds SQLiteTokenStorage which is very similar SQLiteAdapter beyond implementing StorageAdapterV2. Both classes should even be able to use the same storage without causing issues
  • Changes ValidatingStorageAdapater to ValidatingTokenStorage which now implements TokenStorage instead of StorageAdapter
  • Removes IdentifiedOAuthTokenResponse as its functionality is now covered by TokenData

Notes:

  • the default namespace is "DEFAULT" instead of None as originally spec'd this was to not require data migration for SQLiteTokenStorage to use storage previously used by SQLiteAdapter
  • namespace is defined at class initialization rather than passed to each function as originally spec'd. This was to minimize needed changes for SQLiteAdapter and better conform with GlobusApp which will also have one namespace per instance.
  • Its not clear to me that adding namespace support to MemoryTokenStorage changed anything since initializing another MemoryAdapter already partitioned the data in memory. Maybe that value should just be ignored?

📚 Documentation preview 📚: https://globus-sdk-python--980.org.readthedocs.build/en/980/

aaschaer avatar Apr 25 '24 14:04 aaschaer