mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
file locking for oauth2.txt
This commit is contained in:
@@ -28,6 +28,7 @@ import csv
|
|||||||
import datetime
|
import datetime
|
||||||
import difflib
|
import difflib
|
||||||
from email import message_from_string
|
from email import message_from_string
|
||||||
|
from filelock import FileLock
|
||||||
import hashlib
|
import hashlib
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
@@ -1287,6 +1288,10 @@ def readDiscoveryFile(api_version):
|
|||||||
invalidJSONExit(disc_file)
|
invalidJSONExit(disc_file)
|
||||||
|
|
||||||
def getOauth2TxtStorageCredentials():
|
def getOauth2TxtStorageCredentials():
|
||||||
|
lock_file = '%s.lock' % GC_Values[GC_OAUTH2_TXT]
|
||||||
|
lock = FileLock(lock_file, timeout=10)
|
||||||
|
# wait for write before read of oauth2.txt so creds are fresh
|
||||||
|
with lock:
|
||||||
oauth_string = readFile(GC_Values[GC_OAUTH2_TXT], continueOnError=True, displayError=False)
|
oauth_string = readFile(GC_Values[GC_OAUTH2_TXT], continueOnError=True, displayError=False)
|
||||||
if not oauth_string:
|
if not oauth_string:
|
||||||
return
|
return
|
||||||
@@ -13417,6 +13422,9 @@ def writeCredentials(creds):
|
|||||||
systemErrorExit(13, 'Wrong OAuth 2.0 credentials issuer. Got %s, expected one of %s' % (_getValueFromOAuth('iss', creds), ', '.join(expected_iss)))
|
systemErrorExit(13, 'Wrong OAuth 2.0 credentials issuer. Got %s, expected one of %s' % (_getValueFromOAuth('iss', creds), ', '.join(expected_iss)))
|
||||||
creds_data['decoded_id_token'] = GC_Values[GC_DECODED_ID_TOKEN]
|
creds_data['decoded_id_token'] = GC_Values[GC_DECODED_ID_TOKEN]
|
||||||
data = json.dumps(creds_data, indent=2, sort_keys=True)
|
data = json.dumps(creds_data, indent=2, sort_keys=True)
|
||||||
|
lock_file = '%s.lock' %GC_Values[GC_OAUTH2_TXT]
|
||||||
|
lock = FileLock(lock_file, timeout=10)
|
||||||
|
with lock:
|
||||||
writeFile(GC_Values[GC_OAUTH2_TXT], data)
|
writeFile(GC_Values[GC_OAUTH2_TXT], data)
|
||||||
|
|
||||||
def doRequestOAuth(login_hint=None):
|
def doRequestOAuth(login_hint=None):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
python-dateutil
|
python-dateutil
|
||||||
distro; sys_platform == 'linux'
|
distro; sys_platform == 'linux'
|
||||||
|
filelock
|
||||||
google-api-python-client>=1.7.10
|
google-api-python-client>=1.7.10
|
||||||
google-auth
|
google-auth
|
||||||
google-auth-httplib2
|
google-auth-httplib2
|
||||||
|
|||||||
Reference in New Issue
Block a user