MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / TokenCachePersistenceOptions

Class TokenCachePersistenceOptions

web/pgacloud/utils/azure_cache.py:18–59  ·  view source on GitHub ↗

Options for persistent token caching. Most credentials accept an instance of this class to configure persistent token caching. The default values configure a credential to use a cache shared with Microsoft developer tools and :class:`~azure.identity.SharedTokenCacheCredential`.

Source from the content-addressed store, hash-verified

16
17
18class TokenCachePersistenceOptions():
19 """Options for persistent token caching.
20
21 Most credentials accept an instance of this class to configure persistent
22 token caching. The default values configure a credential to use a cache
23 shared with Microsoft developer tools and
24 :class:`~azure.identity.SharedTokenCacheCredential`.
25 To isolate a credential's data from other applications,
26 specify a `name` for the cache.
27
28 By default, the cache is encrypted with the current platform's user data
29 protection API, and will raise an error when this is not available.
30 To configure the cache to fall back to an unencrypted file instead
31 of raising an error, specify `allow_unencrypted_storage=True`.
32
33 .. warning:: The cache contains authentication secrets. If the cache is
34 not encrypted, protecting it is the application's responsibility.
35 A breach of its contents will fully compromise accounts.
36
37 .. literalinclude:: ../tests/test_persistent_cache.py
38 :start-after: [START snippet]
39 :end-before: [END snippet]
40 :language: python
41 :caption: Configuring a credential for persistent caching
42 :dedent: 8
43
44 :keyword str name: name of the cache, used to isolate its data from other
45 applications. Defaults to the name of the cache shared by Microsoft
46 dev tools and :class:`~azure.identity.SharedTokenCacheCredential`.
47 :keyword bool allow_unencrypted_storage: whether the cache should fall
48 back to storing its data in plain text when
49 encryption isn't possible. False by default. Setting this to
50 True does not disable encryption. The cache will
51 always try to encrypt its data.
52 """
53
54 def __init__(self, **kwargs):
55 # type: (**Any) -> None
56 self.allow_unencrypted_storage = \
57 kwargs.get("allow_unencrypted_storage", False)
58 self.name = kwargs.get("name", "msal.cache")
59 self.cache_location = kwargs.get("cache_location", None)
60
61
62def load_persistent_cache(options):

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected