Thursday 4 May 2017

User/Pass Authentication API on NodeJS without Express

I am currently developing an API project using ClaudiaJS API Builder to build and deploy it on AWS Lambda with it's endpoints exposed on AWS API Gateway. I am planning to have at least a webapp and a mobile app for this platform, so I'm focusing mostly everything on API's, including the authentication methods(signup, signin, logout, verify account, ect.).

Unfortunately, as I am not using Express in this project, I can't find a good way to build these auth methods since every library I find has some dependency on Express (e.g PassportJS).

My initial thoughts for the login workflow are:

  1. User submits login form containing user/pass stored in PostgreSQL DB.
  2. Front app calls auth API.
  3. API method compared credentials against the user DB (Using BCrypt).
  4. In case of success, API method generates JWT containing a few user details on it's payload and returns to the consumer app.

Is there any good approach for achieving this goal without using Passport and/or Express? Are there any other libs for this purpose or should I just use a regular db query and generate a JWT in case the evaluation succeeds?

Thanks for everyone in advance.

Best regards, Enrico Bergamo



via Enrico Bergamo

No comments:

Post a Comment