TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How do you implement stateless auth in nodejs?

1 点作者 karangoeluw大约 11 年前
So I&#x27;m making a mobile app, which will use the API I&#x27;m writing. The API will be used only by the mobile app, and not by anyone else (maybe I&#x27;ll allow others with a limited method set?).<p>The API itself, works except I&#x27;m concerned about: - Security - It being stateless<p>I&#x27;m using passport.js for user authentication, and a RedisStore for storing user sessions:<p><pre><code> app.use(express.cookieParser()); app.use(express.session({ secret: secrets.sessionSecret, store: new RedisStore({ host: &#x27;localhost&#x27;, port: 6379 }) })); </code></pre> For api calls that require an authenticated user, I just check if the `req.isAuthenticated()` method is true or not. Pretty standard.<p>However, my reading and research suggests that API&#x27;s that reply on sessions are poor design. How do I change that? What is a good, not complicated design for this kind of a model? What should I be doing given my use case? Any code samples?

暂无评论

暂无评论