/Auth-Service

Provides user signup, login, and profile management

Primary LanguageTypeScriptMIT LicenseMIT

Auth Service

A progressive Node.js service which provides user signup, login, and profile management

Tools

  • Nest - A framework for building efficient and scalable Node.js applications.
  • Auth0 - For secure authentication and authorization
  • JWT - For stateless management of user tokens
  • Swagger - For API documentation

Installation

$ yarn install

Setup

  1. Copy environment variables from .env.sample file in project root into a new .env file in project root
  2. Fill the environment variables with actual values

Running the app

# development
$ yarn start

# watch mode
$ yarn start:dev

# production mode
$ yarn start:prod

Usage

  1. To login, go to the following web address (Replace env variables with actual values):
https://${AUTH0_DOMAIN}/authorize?audience=${BASE_URL}&scope=openid%20profile&response_type=code&client_id=${AUTH0_CLIENT_ID}&redirect_uri=${LOGIN_REDIRECT_URL}&state=STATE?prompt=none
  1. To register, go to the following web address (Replace env variables with actual values):
https://${AUTH0_DOMAIN}/authorize?audience=${BASE_URL}&scope=openid%20profile&response_type=code&client_id=${AUTH0_CLIENT_ID}&redirect_uri=${REGISTER_REDIRECT_URL}}&state=STATE?prompt=none
  1. After login or register, copy the auth_token in your response body and set as bearer token in your request header

  2. With access_token set, you now access the following protected endpoints:

GET /api/me
POST /api/upload
  1. To logout current user: go to the following web address (Replace env variables with actual values):
https://${AUTH0_DOMAIN}/v2/logout?federated

API Documentation

Try it out

  1. Complete the above steps to install and setup the project locally
  2. Start the app
  3. Click Here to register
  4. Copy your auth_token, set as Bearer token in your headers and tryout other endpoints in the docs

Suggested Improvements

  1. Write unit and e2e tests
  2. Upload profile images to cloud and save image url to a database
  3. API docs was rushed, add more details