TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How do you implement stateless auth in nodejs?

1 pointsby karangoeluwabout 11 years ago
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?

no comments

no comments