Skip to content

Commit

Permalink
put: check version/comparison before sealing new secret
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-muir committed Mar 13, 2019
1 parent 654b59c commit ef4273b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions credsmash/api/put.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ def put_secret(
plaintext, version=None, compare=True,
algorithm=ALGO_AES_CTR, **seal_kwargs
):
sealed = seal_secret(
key_service,
plaintext,
algorithm=algorithm,
binary_type=storage_service.binary_type,
**seal_kwargs
)

if version is None:
latest_secret = storage_service.get_one(secret_name)
version = 1
Expand All @@ -31,5 +23,12 @@ def put_secret(
logger.debug('secret "%s" is unchanged', secret_name)
return latest_secret['version']

sealed = seal_secret(
key_service,
plaintext,
algorithm=algorithm,
binary_type=storage_service.binary_type,
**seal_kwargs
)
storage_service.put_one(secret_name, version, sealed)
return version

0 comments on commit ef4273b

Please sign in to comment.