Skip to content

Commit

Permalink
Add csrf plugins + config
Browse files Browse the repository at this point in the history
electrode-csrf-jwt configuration
csrf demo endpoints plugin + configuration
  • Loading branch information
Christopher McMahon committed Sep 8, 2016
1 parent 1c6c6f1 commit 802da88
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"plugins": {
"electrode-csrf-jwt": {
"options": {
"secret": "shhhhhh",
"expiresIn": 60
}
},
"./server/plugins/csrf": {},
"webapp": {
"module": "./server/plugins/webapp",
"options": {
Expand Down
34 changes: 34 additions & 0 deletions server/plugins/csrf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"use strict";
/*eslint-env es6*/
var plugin = {};

/*
Sample endpoints to demonstrate CSRF protection via the electrode-csrf-jwt module.
Note the endpoints require no special configuration for protection to be enabled.
*/
plugin.register = function (server, options, next) {
/* a demo GET endpoint which will return a CSRF cookie + header */
server.route({
method: "GET",
path: "/1",
handler: function (req, reply) {
reply("valid");
}
});
/* a demo POST endpoint which will require a CSRF cookie + header */
server.route({
method: "POST",
path: "/2",
handler: function (req, reply) {
reply("valid");
}
});
next();
};

plugin.register.attributes = {
name: "CSRFPlugin",
version: "0.0.1"
};

module.exports = plugin;

0 comments on commit 802da88

Please sign in to comment.