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

[#13] prevent download of private keys #14

Merged
merged 1 commit into from
Jan 9, 2023

Conversation

pi-sigma
Copy link
Contributor

@pi-sigma pi-sigma commented Dec 30, 2022

Fixes #13 (partly)

  • complements the security patch to django-privates (PR #5) by overriding the private_media_no_download_fields attribute in the admin
  • adds tests for the admin's list and detail views and checks that the latter does not contain a download link for private keys

@codecov-commenter
Copy link

codecov-commenter commented Dec 30, 2022

Codecov Report

Merging #14 (947d7b6) into main (a8bb42d) will increase coverage by 0.31%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #14      +/-   ##
==========================================
+ Coverage   99.26%   99.57%   +0.31%     
==========================================
  Files          15       16       +1     
  Lines         406      470      +64     
==========================================
+ Hits          403      468      +65     
+ Misses          3        2       -1     
Impacted Files Coverage Δ
simple_certmanager/admin.py 100.00% <100.00%> (ø)
tests/test_admin.py 100.00% <100.00%> (ø)
tests/test_certificates.py 100.00% <100.00%> (ø)
simple_certmanager/models.py 100.00% <0.00%> (+1.49%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pi-sigma
Copy link
Contributor Author

pi-sigma commented Dec 30, 2022

At the moment, private keys can still be downloaded by modifying the URL in the address bar of the browser. To prevent this, the view for the private key should not be created. This can be achieved by modifying the admin.PrivateMediaMixin.get_urls method in django-privates. I tried to achieve the same result by overwriting that method in the simple_certmanager.admin.CertificateAdmin class, but to no avail.

@pi-sigma pi-sigma force-pushed the feature/private-key-no-download branch 3 times, most recently from 45f7778 to b2b1704 Compare January 5, 2023 21:05
@pi-sigma pi-sigma marked this pull request as ready for review January 5, 2023 21:09
tox.ini Show resolved Hide resolved


@temp_private_root()
class AdminTests(TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

for the next time - we prefer writing tests in pytest style for libraries, pytest-django provides many useful tools to make tests easier to read and maintain.

tests/test_admin.py Outdated Show resolved Hide resolved
@sergei-maertens sergei-maertens merged commit 45117ca into main Jan 9, 2023
@sergei-maertens sergei-maertens deleted the feature/private-key-no-download branch January 9, 2023 07:52
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.

Prevent download of private keys
3 participants