Skip to content

Commit b91d36a

Browse files
authored
Writing of protected cache in bytes for Windows 10 DPAPI (#52)
1 parent f5a54e6 commit b91d36a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

msal_extensions/persistence.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ def __init__(self, location, entropy=''):
114114
super(FilePersistenceWithDataProtection, self).__init__(location)
115115

116116
def save(self, content):
117-
super(FilePersistenceWithDataProtection, self).save(
118-
self._dp_agent.protect(content))
117+
# type: (str) -> None
118+
with open(self._location, 'wb+') as handle:
119+
handle.write(self._dp_agent.protect(content))
119120

120121
def load(self):
121-
return self._dp_agent.unprotect(
122-
super(FilePersistenceWithDataProtection, self).load())
122+
# type: () -> str
123+
with open(self._location, 'rb') as handle:
124+
return self._dp_agent.unprotect(handle.read())
123125

124126

125127
class KeychainPersistence(BasePersistence):

0 commit comments

Comments
 (0)