Skip to content

Commit

Permalink
return extra context with getSecret
Browse files Browse the repository at this point in the history
  • Loading branch information
kiran committed Feb 8, 2022
1 parent df24f91 commit 09aece1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion credstash.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,19 @@ def getSecret(name, version="", region=None, table="credential-store", context=N
'''
fetch and decrypt the secret called `name`
'''
secret, context = getSecretAndContext(name=name, version=version, region=region,
table=table, context=context, dynamodb=dynamodb,
kms=kms, **kwargs)
return secret


def getSecretAndContext(name, version="", region=None,
table="credential-store", context=None,
dynamodb=None, kms=None, **kwargs):
"""
fetch and decrypt the secret called `name`, and also return its version and
comments.
"""
if not context:
context = {}

Expand Down Expand Up @@ -587,7 +600,10 @@ def getSecret(name, version="", region=None, table="credential-store", context=N

key_service = KeyService(kms, None, context)

return open_aes_ctr_legacy(key_service, material)
return (
open_aes_ctr_legacy(key_service, material),
{"version": material.get("version"), "comment": material.get("comment")}
)


@clean_fail
Expand Down

0 comments on commit 09aece1

Please sign in to comment.