inz.fi

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 53226f0e86d10ba88c22d864f0de514781e331bc
parent 6db087d2c8ca49832c7fe5bbbf13acf82f1eaae4
Author: Santtu Lakkala <inz@inz.fi>
Date:   Thu,  2 Feb 2017 09:27:50 +0000

node.js and wordpress sessions

Diffstat:
Aposts/node-js-and-wordpress-sessions.md | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/posts/node-js-and-wordpress-sessions.md b/posts/node-js-and-wordpress-sessions.md @@ -0,0 +1,16 @@ +# node.js and wordpress sessions + +For a leetle project, I needed a way to validate a wordpress session from node.js. Wordpress uses a somewhat complicated session system, with HMACs and using part of password salt, and was unable to find a ready puzzle piece for the purpose. So I wrote my own. + +The result is [a javascript module](https://inz.fi/p/wpsess.javascript). Sample usage: + + var wps = require('wpsess'); + var vdtor = new wps.Validator('/path/to/my/wp-config.php'); + vdtor.validate('value_of_my_logged_in_cookie', function (err, username) { + if (err) + console.log('Authentication failed: ' + err); + else + console.log('Logged in user: ' + username); + }); + +It is way from perfect, but it works well enough for me.