Skip to content

Commit 16678a4

Browse files
merging with master
2 parents 1b6a9e3 + 69b717c commit 16678a4

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/sumo/wrapper/_auth.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import msal
33
import json
44
import stat
5+
import sys
56
import os
67

78
TENANT = "3aa4a235-b6e2-48d5-9195-7fcf05b459b0"
@@ -65,9 +66,12 @@ def _cache_available(self):
6566
return False
6667

6768
def _check_token_security(self):
69+
if sys.platform.lower().startswith('win'):
70+
return True
71+
6872
access_stats = os.stat(self.token_path)
6973

70-
return not bool(access_stats.st_mode & stat.S_IRWXG)
74+
return not bool(access_stats.st_mode & (stat.S_IRWXG | stat.S_IRWXO))
7175

7276
def _oauth_device_code(self):
7377
flow = self.app.initiate_device_flow(scopes=[self.scope])
@@ -83,12 +87,17 @@ def _oauth_device_code(self):
8387
self._write_cache()
8488

8589
def _write_cache(self):
86-
old_mask = os.umask(000)
90+
old_mask = os.umask(0o077)
91+
92+
dir_path = os.path.dirname(self.token_path)
93+
os.makedirs(dir_path, exist_ok=True)
8794

88-
os.makedirs(os.path.dirname(self.token_path), exist_ok=True, mode=0o700)
8995
with open(self.token_path, "w") as file:
9096
file.write(self.cache.serialize())
91-
os.chmod(self.token_path, 0o600)
97+
98+
if not sys.platform.lower().startswith('win'):
99+
os.chmod(self.token_path, 0o600)
100+
os.chmod(dir_path, 0o700)
92101

93102
os.umask(old_mask)
94103

0 commit comments

Comments
 (0)