Skip to content
This repository has been archived by the owner on Feb 14, 2025. It is now read-only.

Add metadata_only flag to GET /v1/credentials/<ID> #274

Merged
merged 3 commits into from
Mar 19, 2020
Merged

Add metadata_only flag to GET /v1/credentials/<ID> #274

merged 3 commits into from
Mar 19, 2020

Conversation

irhkang
Copy link
Contributor

@irhkang irhkang commented Mar 19, 2020

This PR does 2 things.

  1. Add a metadata_only flag to GET /v1/credentials/. This provides more granular controls for fetching a credential. One benefit this has is that it's very easy to tell when a credential_pair is sent in the response (when metadata_only=False). This gives us an easier way to see when a credential was last decrypted

  2. Update the credential's last decrypted time if the credential_pairs was sent in the response. NOTE: this is opt in - there is a env variable that must be set for the save to occur. We make this opt in to not disturb existing users

permissions['get'] = True
include_credential_pairs = True

if settings.ENABLE_SAVE_LAST_DECRYPTION_TIME:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this opt in - the setting defaults to false

@@ -184,11 +184,11 @@ def next_rotation_date(self):
# If a credential has never been rotated or been decrypted,
# immediately rotate
if self.last_rotation_date is None:
return datetime.utcnow()
return datetime.now()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now() has the timezone so we don't do subtraction between tz aware and tz unaware datetimes

skiptomyliu
skiptomyliu previously approved these changes Mar 19, 2020
CHANGELOG.md Outdated
`metadata_only` defaults to `false` so that it is backwards compatible. The purpose of this
is to give users finer controls when deciding whether to send back `credential_pairs`.
* Automatically update the `last_decrypted_date` on a credential when the `credential_pairs` are
sent back to the client. Sending a credential_pair to the client implies that a credential has been
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit minor formatting: "credential pair" or credential_pair

@irhkang irhkang merged commit 373c0a6 into master Mar 19, 2020
@irhkang irhkang deleted the I-fin branch March 19, 2020 22:12
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants