Giter VIP home page Giter VIP logo

backend-auth's Introduction

Jincor Auth

Codeship Status for JincorTech/backend-auth

Why

There are a lot of authentication services. But we were looking for a containerized simple to use solution with multi tenancy support and suitable for both: user authentication and services/tenants authentication.

Tenant is a user of the system permitted to read and write to database in its scope. If you don't need multi tenancy support, just create 1 tenant and add all users to it.

Service responsibilities

  1. Tenant management
  2. User management
  3. Generation of JWT tokens
  4. Validation of JWT tokens
  5. Authentication

How does it work

Jincor Auth service registers users with their username(login/email), company and tenant ID(for multi tenancy support). When user makes attempt to login with his or her credentials, Auth service is trying to match credentials. If success it generates unique random session key which is used as part of the JWT secret and stores this session to database. This means that no one can validate token without making a call to Auth service because the JWT signature created using specific Auth's secret key and random session id known only by Auth service. This session mechanism is also used to invalidate tokens. Removing session key from the database will do the trick.

Common workflow is following:

  1. Create a user.
  2. Login the user, save received token.
  3. Verify saved token whenever authentication required.
  4. Logout the user when necessary.
  5. Delete the user when his account is not active anymore or deleted.

API Endpoints

For more information, see API Documentation

  1. /tenant POST - register a tenant.
  2. /tenant/login POST - login a tenant.
  3. /tenant/logout POST - logout a tenant.
  4. /tenant/verify POST - verify tenant's JWT token.
  5. /user POST - create a new user.
  6. /user/{login} DELETE - delete specific user.
  7. /auth/ POST - log user in.
  8. /auth/verify POST - verify the given token.
  9. /auth/logout POST - logout user.

How to build

For development

  1. Clone this repo.

  2. Run docker-compose build --no-cache.

  3. Start development containers: docker-compose up -d.

  4. If you want to update/install dependency run: docker-compose exec auth npm i some-dep. IMPORTANT: To keep your changes in container you have to commit it: docker commit registry.jincor.com/backend/auth-develop:latest.

  5. To run tests run docker-compose exec auth npm test

  6. /tenant POST - register a tenant.

  7. /tenant/login POST - login a tenant.

  8. /tenant/logout POST - logout a tenant.

  9. /tenant/verify POST - verify tenant's JWT token.

  10. /user POST - create a new user.

  11. /user/{login} DELETE - delete specific user.

  12. /auth/ POST - log user in.

  13. /auth/verify POST - verify the given token.

  14. /auth/logout POST - logout user.

How to build

For development

  1. Clone this repo.
  2. Run docker-compose build --no-cache
  3. Start development containers: docker-compose up -d
  4. To install dependencies run: docker-compose exec auth npm i
  5. To run tests run docker-compose exec auth npm test

For production

  1. Clone this repo.
  2. Run docker-compose -f docker-compose.prod.yml build --no-cache.
  3. To start prod containers: docker-compose -f docker-compose.prod.yml up -d.
  4. Push to registry: docker push registry.jincor.com/backend/auth:latest.

backend-auth's People

Contributors

artemii235 avatar hlogeon avatar totraev avatar

Watchers

 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.