Introduction
In the Basic Service example, we learned to perform a heartbeat check on a service, in order to monitor its health.
Introduction
...
In the Basic Service example, we learned to perform a heartbeat check on a service, in order to monitor its health.
Moreover, sample tests to expose the basic functionalities of a SOAJS service, and those of the IMFV.
...
This example also introduces the User Registration & Access Control (URAC) service, which holds records of all the tenants and its corresponding users.
...
The code walkthrough is located in a sub page and explained in depth. Click here to read the explanation.
URAC Installation
SOAJS User Registration & Access Control (URAC) is a service that manages the Users records and their Access Controls.
The service is multitenant and provides the ability to have members accounts for different tenants.
Similar to any other SOAJS service, URAC can be installed via NPM:
Service Exploration
...
To turn on URAC in a development environment you just need to start the environment as follow
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#sudo go to soajs directoryservices cd /opt/soajs/node_modules # install urac npm install soajs.urac # go to urac directory cd /opt/soajs/node_modules/soajs.urac # export necessary environment variables export SOAJS_PROFILE=/opt/soajs/node_modules/soajs.utilities/data/getStarted/profile.js export SOAJS_ENV=test export SOAJS_SRVIP=127.0.0.1 # run urac node . |
URAC is now running on http://127.0.0.1:4001 and will be used to login with different users. Therefore, its maintenance port is 5001.
Next, a heartbeat request is sent to check the health of the URAC service.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
curl -X GET "http://127.0.0.1:5001/heartbeat" |
A response similar to the one below indicates a healthy functioning of the URAC service
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{"result": true,"ts": 1425372634090,"service": {"service": "urac","type": "rest","route": "/heartbeat"}} |
Service Exploration
...
start --env=example |
Info | ||
---|---|---|
| ||
To verify if oauth is running you need to login to soajs console and
|
Code Block | ||||
---|---|---|---|---|
| ||||
# go to correct directory examples/example03 and start the service cd soajs.examples/opt/soajs/node_modules/soajs.examples/example03/example03/ # start the soajs example environment sudo soajs services start --env=example # export necessary environment variables to create local awareness export SOAJS_PROFILE=/opt/soajs/node_modules/soajs.utilities/data/getStarted/profile.jsENV=EXAMPLE export SOAJS_SRVPORT=4023 export SOAJS_ENVDEPLOY_MANUAL=test1 export SOAJS_SRVIPREGISTRY_API=127.0.0.1:21000 # start service node . |
The service is now running and listens on port 40124023. Therefore, its maintenance port is 50125023.
Next, a heartbeat request is sent to check the health of the service.
Code Block | ||||
---|---|---|---|---|
| ||||
curl -X GET "http://127.0.0.1:50125023/heartbeat" |
A response similar to the one below indicates a healthy functioning of the service.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
curl -X GET -H "key:4232477ed993d167ec13ccf8836c29c400fef7eb3d175b1f2192b82ebef6fb2d129cdd25fe23c04f856157184e11f7f57b65759191908cb5c664df136c7ad16a56a5917fdeabfc97c92a1f199e457e31f2450a810769ff1b29269bcb3f01e3d24ea5db4c70b6168aeede6a8a56cb4624efdb6cb2cf3c7b88cbc1f5d97080a44f18083fa195e20dcc0b42496ae268ea91c657dd9b252b72de14c862e64f8522a9dbdaa1ce0f48ba2d5ed5eff49b47d0f728bddb2080c8cbc7bde3771116192b51" "http://127.0.0.1:4000/example03/buildName?lastName=Smith&access_token=valid_access_token" |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
curl -X GET -H "key:4232477ed993d167ec13ccf8836c29c4550e88551c880d36fd42223ef81e0a6e1f668d42edc70d3d98fa8d28757e951bd7a04cf43829b5c2f38ed8c9ee87f03b79e564dd6aeaf8c37e90c92e6a69dccbd52b5a7812cad139bfbeaab69b0233224ea5db4c70b6168aeede6a8a56cb4624efdb6cb2cf3c7b88cbc1f5d97080a44f18083fa195e20dcc0b42496ae268ea91c657dd9b252b72de14c862e64f8522a9dbdaa1ce0f48ba2d5ed5eff49b47d0f728bddb2080c8cbc7bde3771116192b51" "http://127.0.0.1:4000/example03/buildName?lastName=Smith" |
...
User | tenant | Overrides Package | Overrides Tenant | buildName | testGet | Custom Tenant Information |
---|---|---|---|---|---|---|
User1 | Tenant1 | NO | NO | NO | NO | NA |
User2 | Tenant1 | YES | NO | YES | YES | Changes the tenant name |
User3 | Tenant1 | NO | YES | YES | NO | Changes the tenant name |
The above table shows three users. Each user has the ability to override the permissions their tenant, and its attributed package.
The examples that follow aim to present how a user can override the ACL permissions of the tenant it belongs to AND/OR the package that the tenant is using.
In addition to that, the examples will show that the user also has the ability to change these configurations, which, in this case, is "tenant name".
User1 Tests
OAUTH Login
Before using the service APIs, a user must be authenticated to the service. Each of the three users has a password. The first step would be to login to OAUTH with a user, and receiving an access token. This access token must be attached to each request.
...
The corresponding response prove the above statement. User2 overrode the package ACL and obtained full access to the service's APIs
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{"result":true,"data":{"firstName":"John","lastName":"Smith"},"soajsauth":"Basic c29hanM6QzAyWWNjQXdaSDBYSnhTMkJ5ejAzZG5RZ1BOdXFFd0d4UmM="} |
...