AccessControl
AccessControl
License: Apache Version 2
new AccessControl()
The AccessControl is a driver to work with TerminusDB and TerminusX access control api for the credential you can use the JWT token, the API token or the basic authentication with username and password
Example
getDefaultOrganization
accessControl.getDefaultOrganization(params) ⇒ string
| undefined
Get a organization from parameters.
Returns: string
| undefined
- - organization
Param | Type | Description |
---|---|---|
params |
| The parameters |
setJwtToken
accessControl.setJwtToken(jwt)
Sets the Jwt token for the object
Param | Type | Description |
---|---|---|
jwt |
| The jwt api token to use |
setApiToken
accessControl.setApiToken(atokenpi)
Sets the API token for the object, to request a token create an account in https://terminusdb.com/
Param | Type | Description |
---|---|---|
atokenpi |
| The API token to use to connect with TerminusX |
setApiKey
accessControl.setApiKey(atokenpi)
Sets the API token for the object, to request a token create an account in https://terminusdb.com/
Param | Type | Description |
---|---|---|
atokenpi |
| The API token to use to connect with TerminusX |
getAPIUrl
accessControl.getAPIUrl(cloudAPIUrl) ⇒ string
Get a API url from cloudAPIUrl
Returns: string
- apiUrl
Param | Type | Description |
---|---|---|
cloudAPIUrl |
| The base url for cloud |
customHeaders
accessControl.customHeaders(customHeaders) ⇒ object
add extra headers to your request
Param | Type |
---|---|
customHeaders |
|
getOrganization
accessControl.getOrganization(organization) ⇒ object
-- TerminusDB API --- Get an organization from the TerminusDB API.
Returns: object
- - organization
Param | Type | Description |
---|---|---|
organization |
| The organization |
getAllOrganizations
accessControl.getAllOrganizations() ⇒ Promise
-- TerminusDB API --- This end point works in basic authentication, admin user Get list of organizations
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
createOrganization
accessControl.createOrganization(orgName) ⇒ Promise
-- TerminusDB API --- This end point works in basic authentication, admin user Create an organization
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
orgName |
| The organization name to create |
Example
deleteOrganization
accessControl.deleteOrganization(orgName) ⇒ Promise
-- TerminusDB API --- Delete an Organization
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
orgName |
| The organization name to delete |
Example
createRole
accessControl.createRole([name], [actions]) ⇒ Promise
--TerminusDB API --- basic authentication, admin user. Create a new role in the system database.
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
[name] |
| The role name. |
[actions] |
| A list of actions |
Example
deleteRole
accessControl.deleteRole([name]) ⇒ Promise
-- TerminusdDB API --- basic Authentication, admin user. Delete role in the system database, (this api is enabled only in the local installation)
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
[name] |
| The role name. |
Example
getAllUsers
accessControl.getAllUsers() ⇒ Promise
-- TerminusdDB API --- basic Authentication, admin user. Return the list of all the users (this api is enabled only in the local installation)
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Example
createUser
accessControl.createUser(name, [password]) ⇒ Promise
-- TerminusdDB API --- basic Authentication, admin user. Add the user into the system database
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
name |
| the user name |
[password] |
| you need the password for basic authentication |
Example
deleteUser
accessControl.deleteUser(userId) ⇒ Promise
-- TerminusdDB API --- basic Authentication, admin user. Remove the user from the system database.
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
userId |
| the document user id |
Example
manageCapability
accessControl.manageCapability(userName, resourceName, rolesArr, operation, scopeType) ⇒ Promise
-- TerminusdDB API --- Grant/Revoke Capability
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
userName |
| the document user id |
resourceName |
| the name of a (database or team) |
rolesArr |
| the roles name list |
operation |
| grant/revoke operation |
scopeType |
| the resource type (database or organization) |
Example
getAccessRoles
accessControl.getAccessRoles() ⇒ Promise
--TerminusX and TerminusDB API --- Get all the system database roles types.
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
getOrgUsers
accessControl.getOrgUsers([orgName]) ⇒ Promise
-- TerminusX and TerminusDB API -- Get all the organization's users and roles,
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
[orgName] |
| The organization name. |
Example
getTeamUserRoles
accessControl.getTeamUserRoles([userName], [orgName]) ⇒ Promise
-- TerminusX and TerminusDB API -- Get the user roles for a given organization or the default organization,
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
[userName] |
| The organization name. |
[orgName] |
| The organization name. |
Example
ifOrganizationExists
accessControl.ifOrganizationExists(orgName) ⇒ Promise
-- TerminusX API --- Check if the organization exists. it is a Head call . IMPORTANT This does not work with the API-TOKEN.
Returns: Promise
- A promise that returns the call status object, 200: if the organization exists and 404: if the organization does not exist
Param | Type | Description |
---|---|---|
orgName |
| The organization name to check if exists. |
createOrganizationRemote
accessControl.createOrganizationRemote(orgName) ⇒ Promise
-- TerminusX API --- IMPORTANT This does not work with the API-TOKEN. Create an organization
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
orgName |
| The organization name to create |
Example
getPendingOrgInvites
accessControl.getPendingOrgInvites([orgName]) ⇒ Promise
-- TerminusX API --- Get the pending invitations list.
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
[orgName] |
| The organization name. |
Example
sendOrgInvite
accessControl.sendOrgInvite(userEmail, role, [note], [orgName]) ⇒ Promise
-- TerminusX API --- Send a new invitation
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
userEmail |
| The email of user. |
role |
| The role for user. (the document @id role like Role/collaborator) |
[note] |
| The note to send with the invitation. |
[orgName] |
| The organization name. |
Example
getOrgInvite
accessControl.getOrgInvite(inviteId, [orgName]) ⇒ Promise
-- TerminusX API --- Get the invitation info
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
inviteId |
| The invite id to retrieve. |
[orgName] |
| The organization name. |
Example
deleteOrgInvite
accessControl.deleteOrgInvite(inviteId, [orgName]) ⇒ Promise
-- TerminusX API --- Delete an invitation
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
inviteId |
| The invite id to delete. |
[orgName] |
| The organization name. |
Example
updateOrgInviteStatus
accessControl.updateOrgInviteStatus(inviteId, accepted, [orgName]) ⇒ Promise
-- TerminusX API --- Accept /Reject invitation. if the invitation has been accepted we add the current user to the organization.
the only user that can accept this invitation is the user registered with the invitation email, we indentify the user with the jwt token
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
inviteId |
| The invite id to updated. |
accepted |
| The status of the invitation. |
[orgName] |
| The organization name. |
Example
getTeamUserRole
accessControl.getTeamUserRole([orgName]) ⇒ Promise
-- TerminusX API --- Get the user role for a given organization or the default organization The user is identified by the jwt or the access token
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
[orgName] |
| The organization name. |
Example
removeUserFromOrg
accessControl.removeUserFromOrg(userId, [orgName]) ⇒ Promise
-- TerminusX API -- Remove an user from an organization, only an admin user can remove an user from an organization
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
userId |
| The id of the user to be removed. (this is the document user's @id) |
[orgName] |
| The organization name in which the user is to be removed. |
Example
getDatabaseRolesOfUser
accessControl.getDatabaseRolesOfUser(userId, [orgName]) ⇒ Promise
-- TerminusX API -- Get the user's role for every databases under the organization
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
userId |
| The user's id. |
[orgName] |
| The organization name. |
Example
createUserRole
accessControl.createUserRole(userId, scope, role, [orgName]) ⇒ Promise
-- TerminusX API -- Create a user's a role for a resource (organization/database)
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
userId |
| The user's id. |
scope |
| The resource name/id. |
role |
| The user role to be assigned. |
[orgName] |
| The organization name. |
Example
updateUserRole
accessControl.updateUserRole(userId, capabilityId, scope, role, [orgName]) ⇒ Promise
-- TerminusX API -- Update user's a role for a resource (organization/database), (this api works only in terminusX)
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
userId |
| The user's id. |
capabilityId |
| The capability id. |
scope |
| The resource name/id. |
role |
| The user role to be updated. |
[orgName] |
| The organization name. |
Example
accessRequestsList
accessControl.accessRequestsList([orgName]) ⇒ Promise
-- TerminusX API -- Get all the access request list for a specify organization
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
[orgName] |
| The organization name. |
Example
sendAccessRequest
accessControl.sendAccessRequest([email], [affiliation], [note], [orgName]) ⇒ Promise
-- TerminusX API -- Get all the access request list for a specify organization
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
[email] |
| the user email. |
[affiliation] |
| the user affiliation, company, university etc.. |
[note] |
| the message for the team admin |
[orgName] |
| The organization name. |
Example
deleteAccessRequest
accessControl.deleteAccessRequest([orgName]) ⇒ Promise
-- TerminusX API -- Delete an access request to join your team, only an admin user can delete it
Returns: Promise
- A promise that returns the call response object, or an Error if rejected.
Param | Type | Description |
---|---|---|
[orgName] |
| The organization name. |
Example
Last updated