Skip to content

Commit 892b73d

Browse files
committed
Updated TODO section.
1 parent caf3572 commit 892b73d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,29 @@ Insert a hidden input field named `csrf_token` in your forms.
5252
<button type="submit">Send</button>
5353
</form>
5454

55+
You can also use following javascript code to perform AJAX calls (jQuery 1.5 and newer).
56+
57+
function csrfSafeMethod(method) {
58+
// HTTP methods that do not require CSRF protection.
59+
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
60+
}
61+
$.ajaxSetup({
62+
crossDomain: false,
63+
beforeSend: function(xhr, settings) {
64+
if (!csrfSafeMethod(settings.type)) {
65+
xhr.setRequestHeader("X-CSRFToken", {{ .csrf_token }});
66+
}
67+
}
68+
});
69+
5570
A demo application is provided in the samples directory. To launch it:
5671

5772
revel run github.com/cbonello/revel-csrf/samples/demo
5873

5974
## TODO
6075

6176
* Routes exemption.
77+
* Logger.
78+
* Unique token per-page.
79+
* Configuration options.
6280
* Test cases.

0 commit comments

Comments
 (0)