Skip to content

Commit

Permalink
Add note about adding CSRF token to Leaf pages
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTim committed Sep 2, 2020
1 parent dafda5d commit c0b165a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ let context = MyPageContext(csrfToken: csrfToken)
return req.view.render("myPage", context)
```

You then need to return the token when the form is submitted. With Leaf, this would look something like:

```html
<form method="post">
<input type="hidden" name="csrfToken" value="#(csrfToken)">
<input type="submit" value="Submit">
</form>
```

### POST routes

You can protect your POST routes either with Middleware or manually verifying the token.
Expand Down

0 comments on commit c0b165a

Please sign in to comment.