-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
electrode-csrf-jwt configuration csrf demo endpoints plugin + configuration
- Loading branch information
Christopher McMahon
committed
Sep 8, 2016
1 parent
1c6c6f1
commit 802da88
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |