Support for api key vault cmd config

This commit is contained in:
Carlos Henrique Guardão Gandarez 2022-11-11 21:55:29 -03:00
parent 54e6772a80
commit 3c2947cf79
No known key found for this signature in database
GPG Key ID: E4B78E04FF214729

View File

@ -194,11 +194,32 @@ class ApiKey(object):
if key: if key:
self._key = key self._key = key
return self._key return self._key
apiKeyFromVault = self.__readFromVaultCmd()
if apiKeyFromVault:
self._key = apiKeyFromVault
return self._key
except: except:
pass pass
return self._key return self._key
def __readFromVaultCmd(self):
apiKeyCmd = SETTINGS.get('api_key_vault_cmd')
if not apiKeyCmd:
return None
try:
p = Popen(apiKeyCmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
stdout, stderr = p.communicate()
if p.returncode == 0:
return stdout.strip()
log(WARNING, u(stderr))
except:
log(ERROR, traceback.format_exc())
return None
def write(self, key): def write(self, key):
global SETTINGS global SETTINGS
self._key = key self._key = key