Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8291669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:12:41+00:00 2026-06-08T13:12:41+00:00

I have a very simple node.js app built on express which has been handling

  • 0

I have a very simple node.js app built on express which has been handling authentication using a session memory store. Basically a user logs in by:

app.post('/sessions', function(req, res) {
            // check username/password and if valid set authenticated to true
        if (authenticated){
            req.session.user = req.body.username;
                } ...
});

Then in each call from the browser a requiresLogin middleware function is called which checks to see if that user property on the session has been set.

I’m now transitioning the app to basically just provide a service that may or may not be consumed in the browser, so instead of using cookies/sessions, I’m considering changing the system so that one would post to /getToken (instead of /sessions) which would return a temporary random token associated with a user’s account that could then be used for a period of time to access the service. Using the service would then require a valid token to be included in each call. (I assume this would be better than passing the username/password each time so that the password would not have to be stored in memory on the client’s computer after the call to get token?)

Would such a system basically be just as secure as the above current system or Is there a much more standard/safe way to handle this? What’s the standard way to handle something like this?

Thanks in advance for you help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:12:42+00:00Added an answer on June 8, 2026 at 1:12 pm

    What you are looking for is called an HMAC and there is a great article here to get ideas on how to implement for your service.

    As to whether session based security is more secure than public/private keypairs is widely debated and really depends on the implementation/application. In your case, since you want per request authentication on a public facing API, the HMAC is the way to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple highcharts js chart, which has dates on x-axis and
I have a very simple set-up. Table Node has a nullable foreign key ObjectId.
I have this very simple C++ class: class Tree { public: Node *head; };
I have a very simple table called Member , which consists of the following:
I have a very simple xml string that I loaded using XmlDocument class. Now
I have a very simple YUI3 script which changes background of a web page.
I m very new to Node.js and Socket.io. I have built a very basic
I have a very simple app running on heroku with nodejs and redis. It
I have very simple xml <root> <node>some value</node> </root> How can I get the
I have very simple piece of code. The goal is when i input four-digit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.