Mashery IODocs - Can it support passportjs authentication from my REST API?

494 views Asked by At

I am using iodocs from Mashery to be the developer front end to my REST API. My API is written with Node / Express, and uses PassportJS to authenticate the user (local strategy). My implementation requires the user to use the /login endpoint, passing in username and password. Then, Passport serializes the user in a cookie, so that subsequent requests do not need to log in.

When using iodocs, the cookie that Passport sets ("connect.sid") is not passed back in subsequent requests.

Is there a way to do this? Is there an authentication method that IODocs supports that works this way?

1

There are 1 answers

0
mansilladev On

Cookies WILL traverse across the ports. An issue you may be encountering is that "connect.sid" is also being set by I/O Docs in that it's using the Express session.js middleware module, so that cookie value is probably getting overwritten.

Try updating I/O Docs app.js with a different cookie name in the session initializer -- setting the "key" value:

app.use(express.session({
    secret: config.sessionSecret,
    key: 'iodocs.connect.sid',
    store:  new RedisStore({
        'host':   config.redis.host,
        'port':   config.redis.port,
        'pass':   config.redis.password,
        'maxAge': 1209600000
    })
}));