JSPM

@lomray/microservice-authorization

1.0.0-beta.48
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 104
  • Score
    100M100P100Q70239F
  • License Apache-2.0

Authorization microservice based on NodeJS & inverted json.

Package Exports

  • @lomray/microservice-authorization
  • @lomray/microservice-authorization/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lomray/microservice-authorization) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

authorization

RPC 2.0 Microservice.
This microservice provides authorization mechanism for all other microservices.

Version
GitHub GitHub package.json dependency version (dev dep on branch)

Quality Gate Status Reliability Rating Security Rating Vulnerabilities Lines of code Coverage

ENVIRONMENTS:

  • NODE_ENV - Can be production or development or tests. Default: development
  • MS_CONNECTION - Invert json host and port (with protocol). Default: http://127.0.0.1:8001
  • MS_CONNECTION_SRV - Invert json connection it is SRV record. Default: false
  • MS_NAME - Microservice name. Default: authorization
  • MS_CONFIG_NAME - Configuration microservice name. Default: configuration
  • MS_WORKERS - Microservice queue workers count. Default: 5
  • MS_ENABLE_REMOTE_MIDDLEWARE - Enable remote middleware feature. Set 0 to disable. Default: 1 (enabled)
  • MS_REMOTE_CONFIG - Enable remote config (get from configuration microservice). Set 0 to disable. Default: 1
  • DB_FROM_CONFIG_MS - Get db credentials from configuration microservice. Set 0 to disable. Default: 1
  • DB_URL - Database url connection string. Default: undefined. Please use URL or credentials.
  • DB_HOST - Database host. Default: 127.0.0.1
  • DB_PORT - Database port. Default: 5432
  • DB_USERNAME - Database user name. Default: postgres
  • DB_PASSWORD - Database password. Default: example
  • DB_DATABASE - Database db name. Default: ms-authorization
  • MS_DEFAULT_ROLE_ALIAS - Default role alias for authenticated users. Default: user
  • MS_DEFAULT_PERMISSION_MIGRATION - Apply migration with default permissions. Default: 0
  • MS_GRAFANA_LOKI_CONFIG - Grafana loki config. Default: null
  • MS_ENABLE_GRAFANA_LOG - Enable grafana loki log (config from configuration ms). Default: 0

HOW TO RUN:

  1. Run Inverted Json job server.
docker run -it -p 8001:8001 lega911/ijson --log 47
  1. Run microservice (please, see ENVIRONMENTS above for understand config)
npm run start:dev
  1. Make some request
curl localhost:8001/ms/authorization -d '{"id": "unique-id", "method": "demo", "params": {}}'

If you use JetBrains IDE, try to find run configurations in .run

You can also install microservice like npm package:

npm i --save @lomray/microservice-authorization

HOW TO DEVELOP:

For develop this microservice, preferred use TDD technique. You can run all tests with watch flag or run one test:

// case 1
npm run test -- --watch

// case 2
NODE_ENV=tests TS_NODE_COMPILER_OPTIONS='{"target":"es6"}' mocha --harmony --no-warnings  __tests__/your-test-name.ts --require ts-node/register --recursive --watch

// check code coverage
nyc npm run test

That is all. Don't forget install npm dependencies (in root folder & local folder run: npm ci)

DEFAULT PERMISSIONS:

Make needed changes in permissions/list. For sync dumped permissions with db, run: npm run sync:permissions

MEMORY USAGE:

Run on typescript: ~205 MB PEAK / ~181 MB
Run on JS: ~33 MB PEAK / ~26 MB AWS Memory: ~100 MB