user3497581 February 2016

Validate the user in AngularJS without any back end calls or Databases

I have created a static website using AngularJS. I am not using any backend calls or database. But I would like to have a login page where the user enters a password (password same for the site users as the site is for internal purposes only), if the password is correct then i take user to the home page else take them back to login scree. I am using Apache Web Server. Is there a way to achieve a safe validation/authentication in AngularJS without Tomcat/Database/Cookies etc ?

Note: I don't want to store username and password in any .js file in a way that it is exposed to any user.

Thanks

Answers


ashfaq.p February 2016

Withouit a server, there is no full proof way of achieving this. However you can encrypt the password and username and then store them in cookies. there are many javascript libraries out there for achieving this. Sample tutorial: Encrypt cookies in browser.

This way its not exposed to user.


STEVER February 2016

Real-world equivalent to only using #JavaScript for input validation.

enter image description here

sorry, for sarcasm.


dundonian February 2016

One option is to add HTTP basic auth to your app. If you host your app with Aerobatic, you might configure this in your package.json like so (note that you can optionally add auth to specific directories):

https://www.aerobatic.com/docs/http-basic-authentication

disclaimer: I'm a co-founder of Aerobatic

{
  "_aerobatic": {
    "router": [
      {
        "module": "basic-auth",
        "path": "/protected",
        "options": {
          "username": "$BASIC_AUTH_USERNAME",
          "password": "$BASIC_AUTH_PASSWORD",
          "loginPage": "login.html",
          "maxFailedLogins": 5,
          "failedLoginPeriod": 600
        }
      },
      {
        "module": "webpage"
      },
      {
        "module": "custom-errors",
        "errors": {
          "403": "403.html"
        }
      }
    ]
  }
}

Post Status

Asked in February 2016
Viewed 2,165 times
Voted 8
Answered 3 times

Search




Leave an answer