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 8251455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:14:29+00:00 2026-06-08T00:14:29+00:00

This is not a question specific about some javascript detail but I’m looking for

  • 0

This is not a question specific about some javascript detail but I’m looking for validation that there are no obvious holes in the model that I’ve created. I decided to roll my own authentication routine (except for using a bcrypt to hash in the backend) which will work like this:

  1. User (browser or phonegap created native app) signs up > Json object posted using jQuery ajax to backend that uses bcrypt to handle the password and save the password user profile data
  2. Backend generates, saves with client IP address a token which it returns (random hash, like /dev/urandom)
  3. jQuery plugin stores the token to a local cookie
  4. When some request is made (post, comment, whatever but not too often) it gets the token from the cookie and adds that to the json and posts it again with ajax
  5. Backend checks that the token exists and has not expired (valid for 7 days), checks that the ip-address is the same and if ok validates the request json data and processes the request
  6. When a token has expired a login screen is shown and credentials posted as ajax and a new token created as in step 2.

Everything goes through ssl for ajax requests and no passwords are stored anywhere. There is also a mechanism checking for brute force token spamming blocking the source ip temporarily if threshold exceeded. This is not a high security app but want to respect users data and make sure it’s secure “enough”.

I hope the question qualifies even though it’s not specific and work as a reference for someone else if it will spark some discussion. I couldn’t find any best practice tutorials on this particular approach.

UPDATE: The authentication mechanism updated according to the feedback received as it seems to be ‘secure enough’ for a non-critical web application.

  • 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-08T00:14:30+00:00Added an answer on June 8, 2026 at 12:14 am

    I have tried to cover everything that I could think of from a high level perspective, given that you said your application isn’t a high security app, and you want the basic security controls in place.

    The authentication flow, and the mechanism that it is using seems fine to me. The only point of concern I see here is the session management itself. Generating a session token using MD5 is fine (depending on whether you are using the correct pseudo random functions, which are seeded the correct way), though SHA1/SHA256 might be better choices if anyone ever tries to create a collision for your tokens.

    I see a few things missing here – they might be omitted, or they might not be there, so I will mention them all. The first thing – you have not mentioned whether you ensure that there is a match between the user, and the cookie that you received. You need to make sure those two match, so that one user cannot steal a second user’s session.

    The second thing I see missing here is validation that the cookie is NOT stolen from the user that it was from. For example, if I managed to steal the session cookie from a user, and replayed it on my own computer from a different place, I would still be able to login, with the current session handling mechanism.

    You need a way to uniquely identify which computer the request is coming from – one way to do it (and the way that a PHP framework called CodeIgniter does it) is by verifying the IP address, as well as the User Agent that the request is coming from. The latter is easy to spoof, but the former is much harder. This makes your session more resilient to attacks – unless the application is used in a internet cafe on a public machine, and the user has not logged off.

    That brings me to my final point – I don’t see a log out mechanism mentioned here, and how the log out is performed. The basic assumption would be that you would invalidate the session cookie as soon as the user logs out, and you don’t accept that session cookie again. If you haven’t done this already, that is something else you can do to ensure your session’s security.

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

Sidebar

Related Questions

This is not a question about a specific framework. I am using plain php
This is not a specific question but a generic question which was in my
This is not a question about jQuery, but about how jQuery implements such a
i have some specific question to solve but i can not think. I have
i'm very aware that this is probably not a stackoverflow question, but i figure
this is not a question about a specific programming problem, it's about examining different
This is a question not really about programming (is not specific to any language
I don't have a specific question here but I'm more looking for some guidance
(This question does not rely on a specific IoC framework, so the interfaces and
This is a general question. And may not be specific to datagrids. How can

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.