Giter VIP home page Giter VIP logo

auth_service's Introduction

FATURA | Backend task

This is authorization and authentication that is responsible for registering users to the system, login, and logout out of the system, and responsible add permission to users & roles

System Desgin

system desgin

Authentication Phase

How authentication work. i used jwt to auth users, user provide email,password,name and role > the server will validate the body of request then if it pass, server will create record fr this user then create two tokens accessToken & refreshToken why i used two

type accessToken refreshToken
expire 30m 1week
used this used for authenticate for every request he is made this is used when accessToken expire to get pair of accessToken & refreshToken then ut become in blacklist for secuirty

register process


when client need data or want to make an action. it will make the request & send accessToken in the headers, so server can extract token , verify it if it verified then return result if not return 401

register process

Installation

to run the app it is very easy, you can use docker-compose to run the app I used docker because I use MySQL as database & Redis for store refresh tokens

i commit .env file for completeness

docker-compose up

server will run http://localhost:3000

Testing

i use jest & supertest run make unit test & write api test to run tests you can run one of the following commands. but before run these command must install deps & and some some env variables

npm i
# mysql
- DB_HOST=localhost
- DB_USER=root
- DB_PASSWORD=abc123
- DB_NAME=db
- DB_PORT=3307

# redis
- REDIS_HOST=localhost
- REDIS_PORT=6379

then you can run tests commands.

# run all tests for the whole app
npm run test

# run all tests of auth endpoints
npm run test:auth

# run all tests of product endpoints
npm run test:product

Postman collection

here is postman collection Postman Collection.

auth_service's People

Contributors

ahmedsaptan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.