For more information, see API Documentation
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
- Tenant management
- User management
- Generation of JWT tokens
- Validation of JWT tokens
- Authentication
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.
- Create a user.
- Login the user, save received token.
- Verify saved token whenever authentication required.
- Logout the user when necessary.
- Delete the user when his account is not active anymore or deleted.
For more information, see API Documentation
/tenant
POST - register a tenant./tenant/login
POST - login a tenant./tenant/logout
POST - logout a tenant./tenant/verify
POST - verify tenant's JWT token./user
POST - create a new user./user/{login}
DELETE - delete specific user./auth/
POST - log user in./auth/verify
POST - verify the given token./auth/logout
POST - logout user.
- Clone this repo.
- Run
$ docker-compose build --no-cache
- Start development containers:
$ docker-compose run auth /bin/sh
- To install dependencies run in container:
$ npm i
- To run tests run in container
$ npm test
- Clone this repo.
- Run
docker-compose -f docker-compose.prod.yml build --no-cache
. - To start prod containers:
docker-compose -f docker-compose.prod.yml up -d
.