Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save archived credential when updating last_decrypted_date #275

Merged
merged 5 commits into from
Mar 20, 2020
Merged

Conversation

irhkang
Copy link
Contributor

@irhkang irhkang commented Mar 19, 2020

This fixes 2 things

  • metadata_only should be parsed with flask_restful.inputs.boolean, not bool as bool() evaluates everything to True. The test for this has changed and now can catch this.

  • When we update the last_decrypted_date of a credential, we also update that field on the archive credential model.

We also limit IDs for GET /v1/credentials/<ID> to be of data type credential (as opposed to credential and archive-credential)

@@ -160,7 +161,7 @@ def get_credential(id):
metadata_only = request.args.get(
'metadata_only',
default=False,
type=bool,
type=inputs.boolean,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See flask-restful/flask-restful#397.

Oddly, I don't remember running into this issue when using reqparse so I assume it's just because I'm using request.args.get. Either way, the bug is definitely fixed now

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how this is an issue. We're not seeing this for the get_service endpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spoke offline - moving to a helper function

@@ -6,6 +6,7 @@

from datetime import datetime
from flask import blueprints, jsonify, request
from flask_restful import inputs
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't add flask_restful, it's deprecated, and we're using blueprints for everything.

credential.save()
# Also try to save the archived credential if ID
# corresponds to a 'credential'
if credential.data_type == 'credential':
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's actually just limit this endpoint to credential.data_type == 'credential' up in line 184

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that causes potential backwards incompatibilities with existing users.

It's not a huge deal in this case though

logger.warning('Archived credential {}-{} not found'.format(
id, credential.revision)
)
return jsonify({}), 404
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should return 404 here. I think we should just continue.

ryan-lane
ryan-lane previously approved these changes Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants