@mimik/oauth-helper
v4.1.3
Published
Oauth helper for mimik microservices
Readme
oauth-helper
Example
import oauthHelper from '@mimik/oauth-helper';- oauth-helper
- ~oauthHelper(config) ⇒ object
- async
- ~rpAuth(type, options) ⇒ Promise
- ~authProfile(method, id, correlationId, [options]) ⇒ Promise
oauth-helper~oauthHelper(config) ⇒ object
Create an OAuth helper instance for making authorized requests.
Kind: inner method of oauth-helper
Returns: object - Object with rpAuth and authProfile methods.
| Param | Type | Description |
| --- | --- | --- |
| config | object | Service configuration. |
| config.security | object | Security settings. |
| config.security.server | object | Token server configuration. |
| config.security.server.issuer | string | Token issuer URL. |
| config.security.server.id | string | Client ID. |
| config.security.server.secret | string | Client secret. |
| config.dependencies | object | Dependency type to settings map. Each entry must have an audience string. |
oauth-helper~rpAuth(type, options) ⇒ Promise
Make an authorized request.
Kind: inner method of oauth-helper
Returns: Promise - Resolves with the response from the authorized request.
Category: async
Throws:
- Error Will throw the same error as request-promise.
The property token may be added to options, in order to set up how the token is retrieved from the token manager. The structure is:
{
"retry": "object to specify how the retry to the token manager will be done. similar to rp-retry retry property",
"customerName": "name of the customer for which the token is intended, see mST API",
"cluster": "to set the token to be a cluster token"
}The property metrics may be added to options, in order to set up metrics about calls made to other microservice. The structure is:
{
"HTTPRequestDuration": "prom-client function to label and record the elapsed time",
"url": "url to be displayed for the metrics. If not present the url of the options will be used"
}Requires: module:@mimik/sumologic-winston-logger
Fulfil: object - Response of the request-promise request.
| Param | Type | Description | | --- | --- | --- | | type | string | Type of micro service to request. | | options | object | Options for the request. Similar to request-promise options. |
oauth-helper~authProfile(method, id, correlationId, [options]) ⇒ Promise
Make an authProfile request to mID.
Kind: inner method of oauth-helper
Returns: Promise - Resolves with the response from mID.
Category: async
Throws:
- Error Will throw a rich error if the request fails or an error if the id is not identified.
Requires: module:@mimik/sumologic-winston-logger
Fulfil: object The response of the request made to mID.
| Param | Type | Description |
| --- | --- | --- |
| method | string | Method (GET, DELETE) of the request to be made. |
| id | string | UserId associated with the request. |
| correlationId | string | CorrelationId associated with the request. |
| [options] | object | Options to be added to the request. metrics can then be added to the options. |
