Replies: 2 comments 1 reply
-
Thanks for the message @ntuckovic! I'm inclined to accept a PR for this functionality even though I do think it should be used with caution -- I will definitely add warnings to the docs if it gets merged in. But, it seems similar to Django itself where CSRF can be disabled entirely if you want. One thought as I read through the Django CSRF docs again: if <div>
<input unicorn:model="name" unicorn:get></input>
</div> Or maybe a modifier: <div>
<input unicorn:model.get="name"></input>
</div> One nice thing about this to me is that the HTML is pretty explicitly saying this is "safe" -- using a setting to turn off CSRF for all I'm wondering if explicitly marking elements as GETs would be a useful feature instead of "setting to turn off CSRF protection" or maybe in addition? Let me know what you think! |
Beta Was this translation helpful? Give feedback.
-
Hmm, interesting.
Yeah, this was my thought as well. However, looking at https://github.com/conformist-mw/django-query-counter gave me an idea: I wonder if I could somehow check that no database changes are happening when the action is a GET? It's theoretical because I haven't tried it out and I'm not sure it's worth it, to be honest, but maybe I could see if it's possible. |
Beta Was this translation helpful? Give feedback.
-
First of all, I want to thank to the author and contributors of this amazing project!
We've discovered it via LinkedIn discussions one year from now and shortly after started to consider an usage in actual production on heavily daily visited frontend project, mainly organised as VUEJS application.
We have discussed about Progressive Enhancement concept for the next re-factor phase, primarily because of simplification benefits and change of main goals of the project.
As we pushed first unicorn component into production we have shortly faced an issue with usage of CRSF token.
The problem is that the every request to the server (not just unicorn ones) includes X-CSRF token into header and
Vary
header is then changed toCookie, Origin
, because of{% csrf_token %}
token placement in the template.This resulted with impossible effective caching of requests for URLs whose responses do not changes so often by 3rd party caching mechanism before application (we use Varnish).
It's completely understandable why CSRF token is used by Unicorn (security, etc...), but since our project does not communicate with DB directly (It's just one of the services that consumes internal API requests) we have decided to fork the project and loosen up security. To be exact we have set the usage of CSRF token as an optional (by default it is enabled) with additional setting variable
USE_CSRF_TOKEN
, you can see changes in the files from forked project PR: https://github.com/Styria-Digital/django-unicorn-loosened/pull/1/filesWe are almost 3 months in production with this altered version of package and there where zero critical situations or bugs in unicorn functionalities when
USE_CSRF_TOKEN
is set toFalse
.Does something like our use case and code changes sounds and looks interesting and helpful for other users/implementators? If so, we might do a PR to official package.
Of course, beside core code implementation of
USE_CSRF_TOKEN
setting, there should be written documentation added to use this with caution.Thank you for all future feedback and discussion!
Beta Was this translation helpful? Give feedback.
All reactions