acs-client
![](http://img.shields.io/npm/v/%40restorecommerce%2Facs%2Dclient.svg?style=flat-square)
![Build Status](http://img.shields.io/travis/restorecommerce/acs-client/master.svg?style=flat-square)
![Dependencies](https://img.shields.io/david/restorecommerce/acs-client.svg?style=flat-square)
![Coverage Status](http://img.shields.io/coveralls/restorecommerce/acs-client/master.svg?style=flat-square)
Features:
- A generic client for the access-control-srv.
- It uses grpc-client to access the exposed API via its gRPC interface.
- This client constructs the request object expected by
access-control-srv
when requesting access to a particular resource with a specific action on it. - This client supports access request for both methods isAllowed and whatIsAllowed exposed by
access-control-srv
. - It evaluates the condition for
whatIsAllowed
requests. - It returns the decision made by the ACS.
Configuration
The access-control-srv
URN configurations needs to be set using authorization configuration to acs-client
from access requesting microservice.
The URN for role scoping entity for Organization/ business units should be set using configuration property authorization.urns.orgScope
.
orgScope: 'urn:<organization>:acs:model:<Entity_Name>'
ex: orgScope: 'urn:restorecommerce:acs:model:organization.Organization'
The applicable policies / rules can be enforced on the request using enforce
configuration
API
The client exposes the following api's:
accessRequest
It turns an API request as can be found in typical Web frameworks like express, koa etc. into a proper ACS request. For write operations it uses isAllowed and for read operations it uses whatIsAllowed operation from access-control-srv.
Requests are performed providing Request
message as input and response is Response
message type. For the read operations it extends the filter provided in the ReadRequst
of the input message to enforce the applicapble poilicies. The response is Decision
or policy set reverse query PolicySetRQ
depending on the requeste operation isAllowed()
or whatIsAllowed()
respectively.
Request
Field | Type | Label | Description |
---|
action | Enum | required | action to be performed on the resource (CREATE , READ , MODIFY , DELETE or ALL ) |
request | Resource or Resource [ ] or ReadRequest | required | list of target resources or read request |
ctx | Context | required | context containing user details (ID and role-associations) |
Response
Field | Type | Label | Description |
---|
Decision | Decision | optional | Access decision; possible values are PERMIT , DENY or INDETERMINATE |
PolicySetRQ | PolicySetRQ [ ] | optional | List of applicable policy sets |
Resource
Field | Type | Label | Description |
---|
type | string | requried | resource entity name |
fields | string [ ] | optional | list of fields for accessing or modifying resource |
instance | string | optional | instance identifier of the resource |
namespace | string | optional | namespace prefix for resource entity |
ReadRequest
Field | Type | Label | Description |
---|
entity | string | requried | resource entity name to be read |
args | io.restorecommerce.resourcebase.ReadRequest | optional | query arguments |
database | string | optional | database for read request, currently arangodb and postgres are supported |
namespace | string | optional | namespace prefix for resource entity |
Decision
Field | Type | Label | Description |
---|
decision | io.restorecommerce.access_control.Decision | required | Access decision; possible values are PERMIT , DENY or INDETERMINATE |
PolicySetRQ
isAllowed
This API exposes the isAllowed
api of access-control-srv
and retruns the response as Decision
.
Requests are performed providing io.restorecommerce.access_control.Request
message as input and response is io.restorecommerce.access_control.Response
message.
whatIsAllowed
This API exposes the isAllowed
api of access-control-srv
and retruns the response as Decision
. Requests are performed providing io.restorecommerce.access_control.Request
message as input and response is io.restorecommerce.access_control.ReverseQuery
message.
Development
Tests
For a simple example on how to use this client with a access-control-srv
check the test cases.
npm run test
Usage
npm install
npm run build