Skip to content

Commit 289a94f

Browse files
committed
Remove old classes that are deprecated for 2 years
1 parent fa1f45b commit 289a94f

File tree

4 files changed

+9
-48
lines changed

4 files changed

+9
-48
lines changed

msal_extensions/__init__.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""Provides auxiliary functionality to the `msal` package."""
22
__version__ = "0.3.1"
33

4-
import sys
5-
64
from .persistence import (
75
FilePersistence,
86
FilePersistenceWithDataProtection,
@@ -12,9 +10,3 @@
1210
from .cache_lock import CrossPlatLock
1311
from .token_cache import PersistedTokenCache
1412

15-
if sys.platform.startswith('win'):
16-
from .token_cache import WindowsTokenCache as TokenCache
17-
elif sys.platform.startswith('darwin'):
18-
from .token_cache import OSXTokenCache as TokenCache
19-
else:
20-
from .token_cache import FileTokenCache as TokenCache

msal_extensions/token_cache.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -89,35 +89,3 @@ def find(self, credential_type, **kwargs): # pylint: disable=arguments-differ
8989
return super(PersistedTokenCache, self).find(credential_type, **kwargs)
9090
return [] # Not really reachable here. Just to keep pylint happy.
9191

92-
93-
class FileTokenCache(PersistedTokenCache):
94-
"""A token cache which uses plain text file to store your tokens."""
95-
def __init__(self, cache_location, **ignored): # pylint: disable=unused-argument
96-
warnings.warn("You are using an unprotected token cache", RuntimeWarning)
97-
warnings.warn("Use PersistedTokenCache(...) instead", DeprecationWarning)
98-
super(FileTokenCache, self).__init__(FilePersistence(cache_location))
99-
100-
UnencryptedTokenCache = FileTokenCache # For backward compatibility
101-
102-
103-
class WindowsTokenCache(PersistedTokenCache):
104-
"""A token cache which uses Windows DPAPI to encrypt your tokens."""
105-
def __init__(
106-
self, cache_location, entropy='',
107-
**ignored): # pylint: disable=unused-argument
108-
warnings.warn("Use PersistedTokenCache(...) instead", DeprecationWarning)
109-
super(WindowsTokenCache, self).__init__(
110-
FilePersistenceWithDataProtection(cache_location, entropy=entropy))
111-
112-
113-
class OSXTokenCache(PersistedTokenCache):
114-
"""A token cache which uses native Keychain libraries to encrypt your tokens."""
115-
def __init__(self,
116-
cache_location,
117-
service_name='Microsoft.Developer.IdentityService',
118-
account_name='MSALCache',
119-
**ignored): # pylint: disable=unused-argument
120-
warnings.warn("Use PersistedTokenCache(...) instead", DeprecationWarning)
121-
super(OSXTokenCache, self).__init__(
122-
KeychainPersistence(cache_location, service_name, account_name))
123-

tests/test_macos_backend.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
pytest.skip('skipping MacOS-only tests', allow_module_level=True)
1111
else:
1212
from msal_extensions.osx import Keychain
13-
from msal_extensions.token_cache import OSXTokenCache
13+
from msal_extensions.token_cache import PersistedTokenCache
14+
from msal_extensions.persistence import KeychainPersistence
1415

1516

1617
def test_keychain_roundtrip():
@@ -26,12 +27,12 @@ def test_osx_token_cache_roundtrip():
2627
client_id = os.getenv('AZURE_CLIENT_ID')
2728
client_secret = os.getenv('AZURE_CLIENT_SECRET')
2829
if not (client_id and client_secret):
29-
pytest.skip('no credentials present to test OSXTokenCache round-trip with.')
30+
pytest.skip('no credentials present to test PersistedTokenCache round-trip with.')
3031

3132
test_folder = tempfile.mkdtemp(prefix="msal_extension_test_osx_token_cache_roundtrip")
3233
cache_file = os.path.join(test_folder, 'msal.cache')
3334
try:
34-
subject = OSXTokenCache(cache_location=cache_file)
35+
subject = PersistedTokenCache(KeychainPersistence(cache_file))
3536
app = msal.ConfidentialClientApplication(
3637
client_id=client_id,
3738
client_credential=client_secret,

tests/test_windows_backend.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
pytest.skip('skipping windows-only tests', allow_module_level=True)
1212
else:
1313
from msal_extensions.windows import WindowsDataProtectionAgent
14-
from msal_extensions.token_cache import WindowsTokenCache
14+
from msal_extensions.token_cache import PersistedTokenCache
15+
from msal_extensions.persistence import FilePersistenceWithDataProtection
1516

1617

1718
def test_dpapi_roundtrip_with_entropy():
@@ -48,8 +49,7 @@ def test_dpapi_roundtrip_with_entropy():
4849

4950
def test_read_msal_cache_direct():
5051
"""
51-
This loads and unprotects an MSAL cache directly, only using the DataProtectionAgent. It is not meant to test the
52-
wrapper `WindowsTokenCache`.
52+
This loads and unprotects an MSAL cache directly, only using the DataProtectionAgent.
5353
"""
5454
localappdata_location = os.getenv('LOCALAPPDATA', os.path.expanduser('~'))
5555
cache_locations = [
@@ -87,12 +87,12 @@ def test_windows_token_cache_roundtrip():
8787
client_id = os.getenv('AZURE_CLIENT_ID')
8888
client_secret = os.getenv('AZURE_CLIENT_SECRET')
8989
if not (client_id and client_secret):
90-
pytest.skip('no credentials present to test WindowsTokenCache round-trip with.')
90+
pytest.skip('no credentials present to test PersistedTokenCache round-trip with.')
9191

9292
test_folder = tempfile.mkdtemp(prefix="msal_extension_test_windows_token_cache_roundtrip")
9393
cache_file = os.path.join(test_folder, 'msal.cache')
9494
try:
95-
subject = WindowsTokenCache(cache_location=cache_file)
95+
subject = PersistedTokenCache(FilePersistenceWithDataProtection(cache_file))
9696
app = msal.ConfidentialClientApplication(
9797
client_id=client_id,
9898
client_credential=client_secret,

0 commit comments

Comments
 (0)