简体   繁体   English

Mashery IODocs-它可以从我的REST API支持passportjs身份验证吗?

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

I am using iodocs from Mashery to be the developer front end to my REST API. 我正在使用Mashery的iodocs作为我的REST API的开发人员前端。 My API is written with Node / Express, and uses PassportJS to authenticate the user (local strategy). 我的API是使用Node / Express编写的,并使用PassportJS来验证用户身份(本地策略)。 My implementation requires the user to use the /login endpoint, passing in username and password. 我的实现要求用户使用/ login端点,并传入用户名和密码。 Then, Passport serializes the user in a cookie, so that subsequent requests do not need to log in. 然后,Passport在cookie中将用户序列化,因此后续请求无需登录。

When using iodocs, the cookie that Passport sets ("connect.sid") is not passed back in subsequent requests. 使用iodocs时,Passport设置的cookie(“ connect.sid”)不会在后续请求中传递回去。

Is there a way to do this? 有没有办法做到这一点? Is there an authentication method that IODocs supports that works this way? IODocs是否支持以这种方式工作的身份验证方法?

Cookies WILL traverse across the ports. Cookies将跨端口穿越。 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. 您可能会遇到的一个问题是,I / O Docs也正在设置“ connect.sid”,因为它使用的是Express session.js中间件模块,因此cookie值可能会被覆盖。

Try updating I/O Docs app.js with a different cookie name in the session initializer -- setting the "key" value: 尝试在会话初始化程序中使用其他Cookie名称更新I / O Docs app.js -设置“键”值:

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
    })
}));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM