refactor url and token to support muiltiple instances of vault
This commit is contained in:
parent
157db684c3
commit
f99b11d50e
|
@ -30,6 +30,22 @@ class VaultDestinationPlugin(DestinationPlugin):
|
||||||
author_url = 'https://github.com/alwaysjolley/lemur'
|
author_url = 'https://github.com/alwaysjolley/lemur'
|
||||||
|
|
||||||
options = [
|
options = [
|
||||||
|
{
|
||||||
|
'name': 'vaultUrl',
|
||||||
|
'type': 'str',
|
||||||
|
'required': True,
|
||||||
|
'validation': '^https?://[a-zA-Z0-9.:-]+$',
|
||||||
|
'helpMessage': 'Valid URL to Hashi Vault instance'
|
||||||
|
'default': 'http://127.0.0.1:8200'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'vaultAuthTokenFile',
|
||||||
|
'type': 'str',
|
||||||
|
'required': True,
|
||||||
|
'validation': '(/[^/]+)+',
|
||||||
|
'helpMessage': 'Must be a valid file path!',
|
||||||
|
'default': '/etc/pki/secrets/vault/token'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'name': 'vaultMount',
|
'name': 'vaultMount',
|
||||||
'type': 'str',
|
'type': 'str',
|
||||||
|
@ -79,13 +95,17 @@ class VaultDestinationPlugin(DestinationPlugin):
|
||||||
cname = common_name(parse_certificate(body))
|
cname = common_name(parse_certificate(body))
|
||||||
|
|
||||||
token = current_app.config.get('VAULT_TOKEN')
|
token = current_app.config.get('VAULT_TOKEN')
|
||||||
url = current_app.config.get('VAULT_URL')
|
#url = current_app.config.get('VAULT_URL')
|
||||||
|
url = self.get_option('vaultUrl', options)
|
||||||
|
token_file = self.get_option('vaultFile', options)
|
||||||
mount = self.get_option('vaultMount', options)
|
mount = self.get_option('vaultMount', options)
|
||||||
path = self.get_option('vaultPath', options)
|
path = self.get_option('vaultPath', options)
|
||||||
bundle = self.get_option('bundleChain', options)
|
bundle = self.get_option('bundleChain', options)
|
||||||
obj_name = self.get_option('objectName', options)
|
obj_name = self.get_option('objectName', options)
|
||||||
|
|
||||||
|
with open(token_file, 'r') as file:
|
||||||
|
token = file.readline()
|
||||||
|
|
||||||
client = hvac.Client(url=url, token=token)
|
client = hvac.Client(url=url, token=token)
|
||||||
if obj_name:
|
if obj_name:
|
||||||
path = '{0}/{1}'.format(path, obj_name)
|
path = '{0}/{1}'.format(path, obj_name)
|
||||||
|
|
Loading…
Reference in New Issue