File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import msal
33import json
44import stat
5+ import sys
56import os
67
78TENANT = "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
You can’t perform that action at this time.
0 commit comments