-
-
Notifications
You must be signed in to change notification settings - Fork 132
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 csrf_tag
helper
#201
Add csrf_tag
helper
#201
Conversation
This lets us easily inject a hidden field containing a CSRF token into a form, while manually controlling all attributes of the form, e.g. `name`, `id`, etc. Fix aantron#199
Note: apologies, but I was unable to get Dream to build due to some errors:
|
Try |
OK, using
Strange... |
Do you have |
Probably would be fixed upstream by anmonteiro/gluten#24. |
I'll pull that commit into Dream's vendored Gluten after this PR, so that people don't have to remove |
Wow, that did the trick! Successfully built after removing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for one question!
example/d-form/README.md
Outdated
@@ -16,7 +16,7 @@ let show_form ?message request = | |||
<p>You entered: <b><%s message %>!</b></p> | |||
% end; | |||
|
|||
<%s! Dream.form_tag ~action:"/" request %> | |||
<form action="/" method="post"><%s! Dream.csrf_tag request %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not put the CSRF field on its own line? It seems like it would be clearer to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, it was mostly that the Django code example does it that way. But I can change it pretty easily.
Thank you! |
@yawaramin, looking at the docs more closely now, I see
Do you have a good reference for that? Asking because the Dream docs are full of references to security articles :) |
@aantron sure, just found it: https://portswigger.net/web-security/csrf/tokens The relevant paragraph is:
|
This lets us easily inject a hidden field containing a CSRF token into
a form, while manually controlling all attributes of the form, e.g.
name
,id
, etc.Fix #199