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

Complete rewrite with a focus on security #232

Merged
merged 2 commits into from Mar 19, 2021
Merged

Complete rewrite with a focus on security #232

merged 2 commits into from Mar 19, 2021

Conversation

codingjoe
Copy link
Collaborator

@codingjoe codingjoe commented Mar 7, 2021

The old design was based on a lot of untested behavior that has
since been included in Django itself, including proper testing
and security oversight.

This refactoring uses those new tools and aims to greatly simplify
the overall design. This simplification should keep potential
exposior to a minimum.

As a result almost all settings have been dropped, infavor
of a simple permission callback and a notification template.
Both can be overriden in a users application to customize
behavior as need.

The documenation is completly rewritten too. It may server
as a good starting point to understand this change.

Changes in a nutshell:

  • Add Material style snackback notification
  • Use permission callbacks instead of settings
  • Provide permission callback for convenience
  • Render and inject notification via middleware
  • Use Django class based views and mixins for permission handling
  • Update the documentation to reflect new design
  • Compile gettext messages during release
  • Switch to SCSS and compile during release
  • Add msgcheck linter for translations
  • Add styleling as a SCSS linter
  • Update translations

@codingjoe
Copy link
Collaborator Author

codingjoe commented Mar 7, 2021

Sorry @Mogost and @utapyngo. Let me explain:

I took the whole weekend to dive into the security aspects of this package. There were many problems. None of which were severe, but needed to be addressed. After some contemplation and some trial an error I ended up removing everything it writing it from scratch. I tried to keep the existing functionality, while making simpler.

A good start to review is the documentation. I put a lot of time into that. However, if you don't feel like reviewing this, please say so. I don't really know how to split this into separate commits, but I can certainly try. That being said, a lot of the new lines come from the NPM package lock.

Best,
Joe

PS: I would create an alpha release, should we decide to merge this, to allow early adopters to play around a little easier.
PPS: Yes, 100% coverage ;)

@codecov-io
Copy link

codecov-io commented Mar 7, 2021

Codecov Report

Merging #232 (3a12c88) into build (449ee71) will increase coverage by 2.61%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##            build     #232      +/-   ##
==========================================
+ Coverage   88.51%   91.13%   +2.61%     
==========================================
  Files           7       11       +4     
  Lines         209      282      +73     
==========================================
+ Hits          185      257      +72     
- Misses         24       25       +1     
Impacted Files Coverage Δ
hijack/__init__.py 100.00% <0.00%> (ø)
hijack/urls.py 100.00% <0.00%> (ø)
hijack/views.py 100.00% <0.00%> (ø)
hijack/decorators.py 90.90% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 449ee71...557eb63. Read the comment docs.

@codingjoe codingjoe force-pushed the v4-alpha branch 5 times, most recently from 0f25b0d to 07f6be9 Compare March 7, 2021 17:36
Copy link
Contributor

@amureki amureki left a comment

Choose a reason for hiding this comment

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

I don't have any production project to test it out (yet), so I just took a general look.

docs/security.md Outdated Show resolved Hide resolved
hijack/locale/cs/LC_MESSAGES/django.po Outdated Show resolved Hide resolved
hijack/conf.py Outdated Show resolved Hide resolved
hijack/middleware.py Show resolved Hide resolved
hijack/models.py Show resolved Hide resolved
@codingjoe
Copy link
Collaborator Author

I split the distribution part from this PR to make it easiert to review.

@Mogost
Copy link
Member

Mogost commented Mar 10, 2021

@codingjoe This version is not compatible with django-hijack-admin
I think a lot of people have these packages installed together.
I don't have a problem with such a big PR and I'm ready to check it out completely. What do you think about making this PR even bigger and pulling the code from django-hijack-admin here (and marking django-hijack-admin as obsolete)?

@codingjoe
Copy link
Collaborator Author

OK, but that would certainly be another commit ;) I'll try to get into it, this weekend :P

@Mogost
Copy link
Member

Mogost commented Mar 10, 2021

OK, but that would certainly be another commit ;)

Then a few more words about rebasing commits. On the one hand it's good that the history looks nice, but on the other hand, when the rebase happens during a review, it's a little hard to track down the changes.
So really, if you're making a commit and not rewriting history, I'm happy about that. 😂

@codingjoe codingjoe force-pushed the build branch 4 times, most recently from 388177e to cca3183 Compare March 14, 2021 11:33
@codingjoe codingjoe force-pushed the build branch 2 times, most recently from d7d7b0c to cabe64f Compare March 14, 2021 11:52
@codingjoe codingjoe changed the base branch from build to master March 15, 2021 15:13
@codingjoe
Copy link
Collaborator Author

@Mogost, I rebased this once and pointed the PR back to the main branch. I will stop rebasing from now on until it's time to merge.

Copy link
Member

@Mogost Mogost left a comment

Choose a reason for hiding this comment

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

It will take me some time to check all this well. So far, the main problem is that the css file is missing during build.

hijack/tests/test_app/urls.py Outdated Show resolved Hide resolved
hijack/tests/test_app/urls.py Outdated Show resolved Hide resolved
hijack/tests/test_views.py Outdated Show resolved Hide resolved
hijack/tests/test_views.py Outdated Show resolved Hide resolved
hijack/tests/test_views.py Outdated Show resolved Hide resolved
hijack/templates/hijack/notification.html Show resolved Hide resolved
Copy link
Member

@Mogost Mogost left a comment

Choose a reason for hiding this comment

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

Looks good to me - Lets get this merged

codingjoe and others added 2 commits March 19, 2021 21:20
The old design was based on a lot of untested behavior that has
since been included in Django itself, including proper testing
and security oversight.

This refactoring uses those new tools and aims to greatly simplify
the overall design. This simplification should keep potential
exposior to a minimum.

As a result almost all settings have been dropped, infavor
of a simple permission callback and a notification template.
Both can be overriden in a users application to customize
behavior as need.

The documenation is completly rewritten too. It may server
as a good starting point to understand this change.

Changes in a nutshell:

* Add Material style snackback notification
* Use permission callbacks instead of settings
* Provide permission callback for convenience
* Render and inject notification via middleware
* Use Django class based views and mixins for permission handling
* Update the documentation to reflect new design
* Compile gettext messages during release
* Switch to SCSS and compile during release
* Add msgcheck linter for translations
* Add styleling as a SCSS linter
* Update translations

Co-Authored-By: Pavel Torbeev <p.torbeev@gmail.com>
Co-authored-by: Alexandr Artemyev <mogost@gmail.com>
@Mogost
Copy link
Member

Mogost commented Mar 19, 2021

Awesome work! @codingjoe
We need to think about the release. Let's start with 3.0rc1 marked as prerelease?

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.

None yet

5 participants