⚙️
API Reference
  • Introduction
  • Features
  • Roadmaps & Requests
  • Frequently Asked Questions
  • Release notes
  • 💡START HERE
    • Terminology
    • Identity and Access Management (IAM)
      • Overview
      • Users in IAM
      • Policies in IAM
      • Roles in IAM
      • Security best practices
    • Dynamic Objects
      • Object Definition
      • Field Definition
      • Data Validation
      • Data Security
        • Encryption
      • Version Control
      • Audit Logs
    • System Architecture Diagram
    • How-To Guides
      • Clinic Project
  • 🔌CORE API Reference
    • Overview
    • Auth
    • Projects
    • Organization
    • Users
    • Roles
    • Policies
    • Objects
    • Item
    • Files
    • Notifications
    • API Request History
    • Auto-Documentation
    • Branches & Merging
    • API Performance
  • ☁️[Coming SOON] YOUR ACCELERATOR PLATFORM ACCOUNT
    • Help and Support
    • Account Page
    • Billing
    • Upgrading an Instance
    • Adjust Server Performance
    • Custom Domain
    • Change Server Region
    • Manage Team
    • API Rate Limit
    • Developer API
  • 🔓SECURITY AND COMPLIANCE
    • Best Practices
    • SOC 2 Type 2 & SOC 3
    • GDPR
    • HIPAA
    • ISO 27001:2013
    • ISO 9001:2015
    • Penetration Testing
  • Accelerator Platform - Core APIs
  • Identity and Access Management
Powered by GitBook
On this page

Identity and Access Management

PreviousAccelerator Platform - Core APIs

Last updated 2 years ago

The Identity and Access Management (IAM) APIs allow developers to manage users, roles, and policies. Based on user roles and policies, These APIs offer row-level and field-level security features to limit data access. In the Accelerator Platform, We can create multiple Projects, Each Project consists of two MongoDB Clusters, One for storing Organization Databases and another for the Authentication Database

Use-case: To understand the functionalities of the Accelerator Platform, We will be implementing the following use case.

  1. We have a organization called Clinic.

  2. There are two type of user Providers and Patients.

  3. Providers can invite a Patients

  4. After Register and Login, users can insert and update their personal information.

  5. Providers can view only those Patients that they are associated with.

  6. Patients can view all the Providers in the Clinic.

The see access the APIs use the following link

In this documentation, I will describe the steps to implement the above use case.

To proceed with the tutorial, you can easily create the necessary Organization and Objects by clicking on the provided link

Project Admins: Project Admins are the users who can create and manage the projects. They can create new projects, organizations, objects, and manage the roles and policies of the projects.

Example:

Step 1. Create a new Project Admin

POST

// Request Body:
{        
  "firstName": "John",
  "lastName": "Doe",
  "email": "john@email.com",
  "password": "Pa$$w0rd"
}

Step 2. Login to Clinic Org as a Project Admin

Response:

200

<project-admin-authtoken>

400

//
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}

401

Unauthorized

Policy: In Accelerator Platform, We can create multiple policies. Each policy is a MongoDB document in the 'policies' collection inside the 'auth' database. below is a list of all the attributes of a policy document.

  1. _id: This is the readonly, unique identifier of the policy. We can use this id to attach the policy to a role.

  2. name: Policy name must be unique in an organization. It should be in the camelCase format.

  3. label: Policy label is used to display the policy name in the UI.

  4. description: To describe the policy.

  5. version: Policy version is use determine which PolicyChecker to use to validate the policy. For Now It is a constant hvaing the value "2023-01".

  6. type: Currently, we have one type of policy which is "ObjectControl" policy. This policy is used to control the access to the items in an object.

  7. object: This is the name of the object to which the policy is applied.

  8. fields: This is use to define the fields level access control.

// "fields": {
    "read": "*",
    "write": ["name", "address", "phoneNumber"]
} 

In the above example, We are allowing the users to read all the fields in the object and write only to the name, address, and phoneNumber fields.

9. conditions: This is used to define the row level access control.

// "conditions": {
    "stringEquals": {
      "email": "{{user.email}}"
    }
}

In the above example, We are allowing the users to access only those items in the object where the email field is equal to the email of the logged-in user.

note: We can also use the {{user.id}} variable if needed.

Example:

Step 3. Create Policies for the Provider and Patient role

a. Provider Data Access Policy: This policy will allow the Providers to access only their own data from the Providers object.

// Request Header:
{
    "Authentication": "bearer <Project-Admin-AuthToken>"
}
Request Body:
{
  "name": "providerDataAccess",
  "label": "Provider Data Access",
  "version": "2023-01",
  "type": "ObjectControl",
  "object": "Providers",
  "fields": {
    "read": "*",
    "write": ["name"]
  },
  "condition": {
    "stringEquals": {
      "email": "{{user.email}}"
    }
  }
}
Response Body:
200
<Provider-Data-Access-Policy-Id>
400
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}
401
Unauthorized

b. Providers Access To Patients Data: This policy will allow the Providers to access only the Patients data that they are associated with.

// Request Header:
{
    "Authentication": "bearer <Project-Admin-AuthToken>"
}
Request Body:
{
  "name": "ProvidersAccessToPatientsData",
  "lebel": "Providers Access To Patients Data",
  "version": "2023-01",
  "type": "ObjectControl",
  "object": "Patients",
  "fields": {
    "read": "*"
  },
  "condition": {
    "stringEquals": {
      "provider": "{{user.id}}"
    }
  }
}
Response Body:
200
<Providers-Access-To-Patients-Data-Policy-Id>
400
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}
401
Unauthorized

Note: While getting Items from Patients Object, The above condition will return those Patients data where the provider field is equal to the id of the logged-in user.

c. Patient Data Access Policy: This policy will allow the Patients to access only their own data from the Patients object.

// Request Header:
{
    "Authentication": "bearer <Project-Admin-AuthToken>"
}
Request Body:
{
  "name": "patientDataAccess",
  "label": "Patient Data Access",
  "version": "2023-01",
  "type": "ObjectControl",
  "object": "Patients",
  "fields": {
    "read": ["name", "email", "provider"],
    "write": "*"
  },
  "condition": {
    "stringEquals": {
      "email": "{{user.email}}"
    }
  }
}
Response:
200
<Patients-Data-Access-Policy-Id>
400
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}
401
Unauthorized

d. Patient’s Access to Providers: This policy will allow the Patients to access basic information of the Providers.

// 
{
    "Authentication": "bearer <Project-Admin-AuthToken>"
}
Request Body:
{
  "name": " patientsAccessToProviders ",
  "label": " Patients Access to Providers",
  "version": "2023-01",
  "type": "ObjectControl",
  "object": "Providers",
  "fields": {
    "read": ["_id", "name", "email" ],
  },
  "condition": {}
  }
}
Response:
200
<Patients-Access-to-Provider-Policy-Id>
400
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}
401
Unauthorized

Roles: A Role is a collection of policies. below is a list of all the attributes of a role document.

  1. _id: This is the readonly, unique identifier of the role. We can use this id to attach the role to a user.

  2. name: Role name must be unique in an organization. It should be in the camelCase format.

  3. policies: This is an array of policy ids.

Example:

Create Roles for the Provider and Patient

// Request Header:
  {
      "Authentication": "bearer <Project-Admin-AuthToken>"
  }
  Request Body:
  {
    "name": "Provider",
    "policies": [
      "<Provider-Data-Access-Policy-Id>",
      "<Providers-Access-To-Patients-Data-Policy-Id>"
    ]
  }
  Response:
200
  <Provider-Role-Id>
400
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}
401
Unauthorized
// Request Header:
  {
      "Authentication": "bearer <Project-Admin-AuthToken>"
  }
  Request Body:
  {
    "name": "Patient",
    "policies": [
      "<Patients-Data-Access-Policy-Id>",
"<Patients-Access-to-Provider-Policy-Id>"
    ]
  }
  Response Body:
200
  <Patient-Role-Id>
400
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}
401
Unauthorized

User Invitation: Project admins, along with Users who have the 'sendInvite' flag set to true, have the ability to send invitations to other users for the organization they are currently logged into. The InviteUser API Endpoints allow sending an Invitation code to a user's email, which can be used during their organization registration process

Example:

Step 4. Invite Providers who can invite Patients to "Clinic" organization

// Request Header:
{
  "Authentication": "bearer <Project-Admin-AuthToken>"
}
Request Body:
{
  "Type": "email",
  "ContentType": "html",
  "Subject": "Provider Invitation",
  "SenderName": "Touchcore System",
  "SenderEmail": "no-reply@touchcore-projects.com",
  "RecipientList": [ "provider.ajay@gmail.com" ],
  "TemplateId": "user_invitation",
  "Vars": { "firstName": "Ajay", "role": "Provider", "orgName": "Clinic.org" }
}
Response :
200
User with id <user-id> successfully invited
400
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}

401
Unauthorized

User Registration Example:

Step 5. Register Providers

// Request Body:
{
  "email": "provider.ajay@gmail.com",
  "orgDomain": "clinic",
  "invitationCode": "123456",
  "password": "S@mplePass0rd"  
}
200
<provider-id>
400
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}

Step 6. Authorize Providers

// 400
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "00-d8e7cef64a92d286849ae53583ab4775-c0cabf25d7ac41cb-00",
  "errors": { ...  }
}

Note: Using the auth token of the Provider, It is possible to insert an Item to the Provider Object. Do the same for the Patients Object. Check out the IAM documentation to know more.

GET

POST

POST

POST

a. POST

b. POST

POST

POST

GET

https://qa.accelerator-platform.com/swagger/index.html
here
https://qa.accelerator-platform.com/api/v1/ProjectAdminSignUp
https://qa.accelerator-platform.com/api/v1/AuthorizeProjectAdmin?orgDomain=clinic&email=john@email.com&password=Pa$$w0rd
https://qa.accelerator-platform.com/api/v1/CreatePolicy
https://qa.accelerator-platform.com/api/v1/CreatePolicy
https://qa.accelerator-platform.com/api/v1/CreatePolicy
https://dev.accelerator-platform.com/api/v1/CreateRole
https://qa.accelerator-platform.com/api/v1/CreateRole
https://dev.accelerator-platform.com/api/v1/InviteUser/<Provider-Role-Id>?sendInvite=true&sendInviteRole=<Patient-Role-Id>
https://dev.accelerator-platform.com/api/v1/Register
https://qa.accelerator-platform.com/api/v1/Authorize?email=provider.ajay@gmail.com&password=S@mplePass0rd