This file contains a set of functions which makes authentication easier.
Methods
(static) assembleScope(tenantopt, organisationopt, useropt) → {string}
- Source:
- See:
Assemble the scope form the given individual pieces.
The scope is used to identify what the authenticated is allowed to do. It can slo be used by admin and tenant users to impersonate as a tenant, organisation or user.
Keep in mind that in order to specify the user, the scope also needs to be specified.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
tenant |
string |
<optional> |
The ID of the tenant which is requesting this scope. |
organisation |
string |
<optional> |
The ID of the organisation which is requesting this scope. |
user |
string |
<optional> |
The ID of the user which is requesting this scope. |
Throws:
-
- When no arguments are provided.
- Type
- Error
Returns:
- The assembled scope.
- Type
- string
(static) authenticate(username, password, scopeopt) → {Promise}
- Source:
Authenticate for the given credentials with the given scope.
On a successful authentication, the settings are updated so every follow-up API requests is authorized by the currently authenticated user.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
username |
string | The username to authenticate with. |
|
password |
string | The password to authenticate with. |
|
scope |
string |
<optional> |
The scope of the authentication. Omitting this value will cause the API to infer the scope. |
Returns:
- A promise which will resolve if the authentication concluded successfully, it'll reject in any other case. It resolves with the response body of the token request.
- Type
- Promise
(static) impersonate(scopeopt) → {Promise}
- Source:
- See:
Impersonate some other tenant, user or organisation. The impersonation will be done by using the authorisation token for the current user.
On a successful impersonation, the settings are updated so every follow-up API requests is authorized by the access_token required with this impersonation.
As an admin or tenant user it is possible to do impersonation. This goes from top to down. So, a tenant user can impersonate an organisation, or an user in an organisation. But an user can't impersonate.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
scope |
string |
<optional> |
The scope of the impersonation. Omitting this value will cause the API to return a token for the current user. |
Returns:
- A promise which will resolve if the authentication concluded successfully, it'll reject in any other case. It resolves with the response body of the token request.
- Type
- Promise