Extract the field from the secret.

This commit is contained in:
Adam Migus
2021-07-14 17:24:52 -04:00
parent 9dc84d69d5
commit 77ab35e7a8

View File

@@ -1,7 +1,7 @@
from .plugin import CredentialPlugin from .plugin import CredentialPlugin
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from thycotic.secrets.server import SecretServer, PasswordGrantAuthorizer from thycotic.secrets.server import PasswordGrantAuthorizer, SecretServer, ServerSecret
tss_inputs = { tss_inputs = {
'fields': [ 'fields': [
@@ -32,14 +32,22 @@ tss_inputs = {
'help_text': _('The integer ID of the secret'), 'help_text': _('The integer ID of the secret'),
'type': 'string', 'type': 'string',
}, },
{
'id': 'secret_field',
'label': _('Secret Field'),
'help_text': _('The field to extract from the secret'),
'type': 'string',
},
], ],
'required': ['server_url', 'username', 'password', 'secret_id'], 'required': ['server_url', 'username', 'password', 'secret_id', 'secret_field'],
} }
tss_plugin = CredentialPlugin( tss_plugin = CredentialPlugin(
'Thycotic Secret Server', 'Thycotic Secret Server',
tss_inputs, tss_inputs,
lambda **kwargs: SecretServer(kwargs['server_url'], PasswordGrantAuthorizer(kwargs['server_url'], kwargs['username'], kwargs['password'])).get_secret( lambda **kwargs: ServerSecret(
kwargs['secret_id'] **SecretServer(kwargs['server_url'], PasswordGrantAuthorizer(kwargs['server_url'], kwargs['username'], kwargs['password'])).get_secret(
), kwargs['secret_id']
)
).fields[kwargs['secret_field']],
) )