A rel=me auth middleware implementation in node.js. Works with any connect-type web application
This is a very simple IndieAuth (or rel='me' auth) middleware (Connect) for Node.js. The main design goal is to enable a dead simple auth inside any Connect-type application.
npm install relmeauth
It requires that you use the bodyParser middleware, the cookieParser middleware (for the session).
var express = require'express';var relme = require'relmeauth';var app = express;appuseexpressbodyParser;appuseexpresscookieParser;appuseexpresssessionsecret: "A secret for the Sessions encryption";appuserelmemiddlewareroot: ''providers:'google.com':id: 'xxxxx'secret: 'yyyyy''github.com':id: 'xxxxx'secret: 'yyyyy';appget'/private' relmeauthenticatedresend'This is a scret that you can now only if youre authentified.';;applisten8080
Test it in on this site.
You can initialize the middleware by providing a configuration object. Options include
- prefix: the prefix for all the relmeauth urls. Default is
relmeauth. Change it if it conflicts with your application.
- authPage: the page on which the user will be asked to submit his indieAuth url. The form must be of GET method and the
url provided' name must be
- authErrorPage: the page on which error messages will be displayed. The error message is accessible in response.authError
appuserelmemiddlewareprefix: 'auth'root: ''// Render whatever makes sense to render on the authPage. You can also redirect... etc.// Render whatever makes sense to render on the authErrorPage;