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

Add ability to encrypt forms after creation #1708

Merged
merged 25 commits into from
Nov 1, 2019

Conversation

DavisRayM
Copy link
Contributor

@DavisRayM DavisRayM commented Oct 27, 2019

This PR implements the ability to encrypt forms after they have being created through a PATCH request with a payload like:

{
    "public_key": "MII...."
}
  • Add ability to encrypt forms on PATCH
  • Write tests

Sample Payload

{
    "public_key": "some_rsa_key"
}

Copy link
Member

@ukanga ukanga left a comment

Choose a reason for hiding this comment

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

I think you should look in the direction of changing the XML, see xform.py#L788 and xform.py#L180. You want to add the base64RsaPublicKey as an attribute on the submission node. If you can shift away from the regex in XML as the examples I have pointed out to by using xml.etree.cElementTree.

@DavisRayM DavisRayM force-pushed the add-encrypt-on-partial-update branch 5 times, most recently from 3ed5731 to 90a8dd4 Compare October 30, 2019 13:50
@DavisRayM DavisRayM changed the title [WIP] Add ability to encrypt forms after creation Add ability to encrypt forms after creation Oct 30, 2019
onadata/apps/logger/models/xform.py Outdated Show resolved Hide resolved
onadata/settings/travis_test.py Outdated Show resolved Hide resolved
@DavisRayM DavisRayM force-pushed the add-encrypt-on-partial-update branch 3 times, most recently from 76c7f6a to da766b7 Compare October 31, 2019 04:30
DavisRayM and others added 17 commits October 31, 2019 10:11
- Add public_key field
- Add add_xls_encryption_settings function
- Add ability to replace form with an encrypted form
- Fix Issue where the xls file was unretrievable on Staging and Development servers
- Added `get_base64RsaPublicKey` helper function to retrieve
  base64RsaPublicKey
- Added `_update_public_key` helper function to update form
  with the submitted public key

Signed-off-by: Mark Ekisa <[email protected]>
Co-authored-by: Davis Raymond <[email protected]>
Signed-off-by: Mark Ekisa <[email protected]>
Co-authored-by: Davis Raymond <[email protected]>
- Clean public_key before setting
- Update json and xml after public_key set
- Only update json and xml when the XForm has no submissions
- Remove _clean_public_key method
- Validate public_key
- Clean public_key
- Test that public_key is updatable
@DavisRayM DavisRayM force-pushed the add-encrypt-on-partial-update branch from da766b7 to e8c2f28 Compare October 31, 2019 07:11
@ukanga ukanga merged commit 83f0c3b into master Nov 1, 2019
@ukanga ukanga deleted the add-encrypt-on-partial-update branch November 1, 2019 05:18
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.

3 participants