I have a REST API application, implemented using Express on NodeJs. I wanted to add authentication, and decided to use everyauth, as we need authentication through social network sites in future. I copy & pasted everyauth example for password from https://github.com/bnoguchi/everyauth (Password Authentication section). When I use the connect to implement REST API, a post to
http://localhost:3000/login
enters the everyauth.password.authenticate method. The connect code is as given below.
var connect = require('connect');
connect(
connect.bodyParser()
, connect.cookieParser()
, connect.session({secret: 'whodunnit'})
, everyauth.middleware()
).listen(3000);
However, when I switch the code to express, as shown below, post to
http://localhost:3000/login
gives 404 - "Cannot POST /login". I am not sure why everyauth is not adding the path "login" to express.
var express = require('express');
var http = require('http');
var everyauth = require('everyauth');
var app = express();
app.configure (function () {
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({"secret": "0123456789"}));
app.use(everyauth.middleware(app));
});
app.listen(3000);
Can someone please help to resolve this.