GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sdk-js/packages/epilot-sdk-v2/docs/permissions.md at main · epilot-dev/sdk-js

Expand file tree

/

permissions.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
1035 lines (854 loc) · 17.6 KB
/

permissions.md

Copy path

File metadata and controls

1035 lines (854 loc) · 17.6 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Permissions API

  • Base URL: https://permissions.sls.epilot.io
  • Full API Docs: https://docs.epilot.io/api/permissions

Usage

import { epilot } from '@epilot/sdk'

epilot.authorize(() => '<token>')
const { data } = await epilot.permissions.listCurrentRoles(...)

Tree-shakeable import

import { getClient, authorize } from '@epilot/sdk/permissions'

const permissionsClient = getClient()
authorize(permissionsClient, () => '<token>')
const { data } = await permissionsClient.listCurrentRoles(...)

Operations

Roles

  • listCurrentRoles
  • listAllRoles
  • createRole
  • searchRoles
  • getRole
  • putRole
  • deleteRole
  • refreshPermissions

Assignments

  • getAssignedRolesForUser
  • assignRoles
  • addAssignment
  • removeAssignment
  • listAllAssignments

Schemas

  • TokenRestrictions
  • Grant
  • GrantWithDependencies
  • GrantCondition
  • EqualsCurrentUserCondition
  • NotEqualsCurrentUserCondition
  • EqualsCondition
  • NotEqualsCondition
  • RoleId
  • BaseRole
  • BaseRoleForCreate
  • UserRole
  • OrgRole
  • ShareRole
  • PartnerRole
  • PortalRole
  • Role
  • RolePayload
  • Assignment
  • InternalAssignment
  • Assignments
  • UserId
  • OrganizationId
  • Slug
  • RoleSearchInput
  • CreateRolePayload
  • Error

listCurrentRoles

Returns roles and grants assigned to current user.

GET /v1/permissions/me

const { data } = await client.listCurrentRoles()
Response
{
  "roles": [
    {
      "id": "123:owner",
      "name": "Owner",
      "slug": "owner",
      "type": "user_role",
      "expires_at": "2028-07-21T17:32:28Z",
      "organization_id": "123",
      "grants": [
        {
          "action": "entity-read",
          "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
          "effect": "allow",
          "conditions": [
            {
              "attribute": "workflows.primary.task_name",
              "operation": "equals",
              "values": ["Qualification"]
            }
          ]
        }
      ],
      "parent_role": "123:owner",
      "vendor_created": true
    }
  ],
  "token_restrictions": {
    "read_only": true,
    "anonymize": true,
    "allowed_actions": ["journey:*", "entity:view"],
    "actor": {
      "type": "agent",
      "agent_id": "string",
      "host_id": "string",
      "purpose": "string"
    }
  }
}

listAllRoles

Returns list of all roles in organization

GET /v1/permissions/roles

const { data } = await client.listAllRoles()
Response
{
  "roles": [
    {
      "id": "123:owner",
      "name": "Owner",
      "slug": "owner",
      "type": "user_role",
      "expires_at": "2028-07-21T17:32:28Z",
      "organization_id": "123",
      "grants": [
        {
          "action": "entity-read",
          "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
          "effect": "allow",
          "conditions": [
            {
              "attribute": "workflows.primary.task_name",
              "operation": "equals",
              "values": ["Qualification"]
            }
          ]
        }
      ],
      "parent_role": "123:owner",
      "vendor_created": true
    }
  ]
}

createRole

Create role

POST /v1/permissions/roles

const { data } = await client.createRole(
  null,
  {},
)
Response
{
  "id": "123:owner",
  "name": "Owner",
  "slug": "owner",
  "type": "user_role",
  "expires_at": "2028-07-21T17:32:28Z",
  "organization_id": "123",
  "grants": [
    {
      "action": "entity-read",
      "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
      "effect": "allow",
      "conditions": [
        {
          "attribute": "workflows.primary.task_name",
          "operation": "equals",
          "values": ["Qualification"]
        }
      ]
    }
  ],
  "parent_role": "123:owner",
  "vendor_created": true
}

searchRoles

Search Roles

POST /v1/permissions/roles:search

const { data } = await client.searchRoles(
  null,
  {
    role_ids: ['123:manager', '456:owner'],
    org_ids: ['123', '456'],
    slugs: ['manager', 'owner'],
    query: 'Administrator',
    limit: 1,
    offset: 1
  },
)
Response
{
  "hits": 0,
  "results": [
    {
      "id": "123:owner",
      "name": "Owner",
      "slug": "owner",
      "type": "user_role",
      "expires_at": "2028-07-21T17:32:28Z",
      "organization_id": "123",
      "grants": [
        {
          "action": "entity-read",
          "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
          "effect": "allow",
          "conditions": [
            {
              "attribute": "workflows.primary.task_name",
              "operation": "equals",
              "values": ["Qualification"]
            }
          ]
        }
      ],
      "parent_role": "123:owner",
      "vendor_created": true
    }
  ]
}

getRole

Get role by id

GET /v1/permissions/roles/{roleId}

const { data } = await client.getRole({
  roleId: 'example',
})
Response
{
  "id": "123:owner",
  "name": "Owner",
  "slug": "owner",
  "type": "user_role",
  "expires_at": "2028-07-21T17:32:28Z",
  "organization_id": "123",
  "grants": [
    {
      "action": "entity-read",
      "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
      "effect": "allow",
      "conditions": [
        {
          "attribute": "workflows.primary.task_name",
          "operation": "equals",
          "values": ["Qualification"]
        }
      ]
    }
  ],
  "parent_role": "123:owner",
  "vendor_created": true
}

putRole

Create or update role

PUT /v1/permissions/roles/{roleId}

const { data } = await client.putRole(
  {
    roleId: 'example',
  },
  {
    id: '123:owner',
    name: 'Owner',
    slug: 'owner',
    type: 'user_role',
    expires_at: '2028-07-21T17:32:28Z',
    organization_id: '123',
    grants: [
      {
        action: 'entity-read',
        resource: 'entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947',
        effect: 'allow',
        conditions: [
          {
            attribute: 'workflows.primary.task_name',
            operation: 'equals',
            values: ['Qualification']
          }
        ]
      }
    ],
    parent_role: '123:owner',
    vendor_created: true
  },
)
Response
{
  "id": "123:owner",
  "name": "Owner",
  "slug": "owner",
  "type": "user_role",
  "expires_at": "2028-07-21T17:32:28Z",
  "organization_id": "123",
  "grants": [
    {
      "action": "entity-read",
      "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
      "effect": "allow",
      "conditions": [
        {
          "attribute": "workflows.primary.task_name",
          "operation": "equals",
          "values": ["Qualification"]
        }
      ]
    }
  ],
  "parent_role": "123:owner",
  "vendor_created": true
}

deleteRole

Delete role by id

DELETE /v1/permissions/roles/{roleId}

const { data } = await client.deleteRole({
  roleId: 'example',
})
Response
{
  "id": "123:owner",
  "name": "Owner",
  "slug": "owner",
  "type": "user_role",
  "expires_at": "2028-07-21T17:32:28Z",
  "organization_id": "123",
  "grants": [
    {
      "action": "entity-read",
      "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947",
      "effect": "allow",
      "conditions": [
        {
          "attribute": "workflows.primary.task_name",
          "operation": "equals",
          "values": ["Qualification"]
        }
      ]
    }
  ],
  "parent_role": "123:owner",
  "vendor_created": true
}

refreshPermissions

Makes sure the user has a role in the organization

GET /v1/permissions/refresh

const { data } = await client.refreshPermissions()

getAssignedRolesForUser

Get list of assigned roles by user id

GET /v1/permissions/assignments/{userId}

const { data } = await client.getAssignedRolesForUser({
  userId: 'example',
})
Response
["123:owner"]

assignRoles

Assign / unassign roles to users.

PUT /v1/permissions/assignments/{userId}

const { data } = await client.assignRoles(
  {
    userId: 'example',
  },
  ['123:owner'],
)
Response
["123:owner"]

addAssignment

Assign a user to a role.

POST /v1/permissions/assignments/{userId}/{roleId}

const { data } = await client.addAssignment({
  userId: 'example',
  roleId: 'example',
})
Response
{
  "user_id": "1",
  "roles": ["123:owner"]
}

removeAssignment

Remove role assignment from user

DELETE /v1/permissions/assignments/{userId}/{roleId}

const { data } = await client.removeAssignment({
  userId: 'example',
  roleId: 'example',
})
Response
{
  "user_id": "1",
  "roles": ["123:owner"]
}

listAllAssignments

Returns list of all assignments in organization

GET /v1/permissions/assignments

const { data } = await client.listAllAssignments()
Response
{
  "assignments": [
    {
      "user_id": "1",
      "roles": ["123:owner"]
    }
  ]
}

Schemas

TokenRestrictions

Restrictions the calling token puts on top of its roles. Only present for restricted tokens.

type TokenRestrictions = {
  read_only?: boolean
  anonymize?: boolean
  allowed_actions?: string[]
  actor?: {
    type?: string
    agent_id?: string
    host_id?: string
    purpose?: string
  }
}

Grant

type Grant = {
  action: string
  resource?: string
  effect?: "allow" | "deny"
  conditions?: object[]
}

GrantWithDependencies

type GrantWithDependencies = {
  action: string
  resource?: string
  effect?: "allow" | "deny"
  conditions?: object[]
  dependencies?: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
}

GrantCondition

type GrantCondition = object

EqualsCurrentUserCondition

Check if any relation_user attribute on the entity contains the current user. When attribute is provided, only that specific attribute path is checked. When attributes is provided, it takes precedence over attribute and the condition passes when the current user appears in ANY of the listed attribut

type EqualsCurrentUserCondition = {
  attribute?: string
  attributes?: string[]
  operation: "equals_current_user"
}

NotEqualsCurrentUserCondition

Check if the current user is absent from the relation_user attributes on the entity. When attribute is provided, only that specific attribute path is checked. When attributes is provided, it takes precedence over attribute and the condition passes only when the current user appears in NONE of the li

type NotEqualsCurrentUserCondition = {
  attribute?: string
  attributes?: string[]
  operation: "not_equals_current_user"
}

EqualsCondition

Check if attribute equals to any of the values

type EqualsCondition = {
  attribute: string
  operation: "equals"
  values: unknown[]
}

NotEqualsCondition

Passes when the attribute does not equal any of the values. Records where the attribute is missing or empty pass the condition.

type NotEqualsCondition = {
  attribute: string
  operation: "not_equals"
  values: unknown[]
}

RoleId

Format: <organization_id>:<slug>

type RoleId = string

BaseRole

type BaseRole = {
  id: string
  name: string
  slug: string
  type: string
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
}

BaseRoleForCreate

type BaseRoleForCreate = {
  id?: string
  name: string
  slug: string
  type: string
  expires_at?: string // date-time
  organization_id?: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
}

UserRole

type UserRole = {
  id: string
  name: string
  slug: string
  type: "user_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
  parent_role?: object
  vendor_created?: boolean
}

OrgRole

type OrgRole = {
  id: string
  name: string
  slug: string
  type: "org_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
  pricing_tier?: string
}

ShareRole

type ShareRole = {
  id: string
  name: string
  slug: string
  type: "share_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
}

PartnerRole

type PartnerRole = {
  id: string
  name: string
  slug: string
  type: "partner_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
  partner_org_id?: object
  vendor_enforced_user_limit?: number
  vendor_created?: boolean
}

PortalRole

type PortalRole = {
  id: string
  name: string
  slug: string
  type: "portal_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
  portal_id?: string
}

Role

type Role = {
  id: string
  name: string
  slug: string
  type: "user_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
  parent_role?: object
  vendor_created?: boolean
} | {
  id: string
  name: string
  slug: string
  type: "org_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
  pricing_tier?: string
} | {
  id: string
  name: string
  slug: string
  type: "share_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
} | {
  id: string
  name: string
  slug: string
  type: "partner_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
  partner_org_id?: object
  vendor_enforced_user_limit?: number
  vendor_created?: boolean
} | {
  id: string
  name: string
  slug: string
  type: "portal_role"
  expires_at?: string // date-time
  organization_id: string
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
  portal_id?: string
}

RolePayload

type RolePayload = {
  grants?: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
    dependencies?: Array<{
      action: { ... }
      resource?: { ... }
      effect?: { ... }
      conditions?: { ... }
    }>
  }>
}

Assignment

A role attached to an user

type Assignment = {
  user_id?: string
  roles?: string[]
}

InternalAssignment

A role attached to an user

type InternalAssignment = {
  userId?: string
  roles?: string[]
}

Assignments

List of role ids attached to an user

type Assignments = string[]

UserId

Id of a user

type UserId = string

OrganizationId

Id of an organization

type OrganizationId = string

Slug

Slug of a role; for a role with id = 123:manager -> 123 is org_id & manager is slug

type Slug = string

RoleSearchInput

type RoleSearchInput = {
  role_ids?: string[]
  org_ids?: string[]
  slugs?: string[]
  query?: string
  limit?: number
  offset?: number
}

CreateRolePayload

type CreateRolePayload = {
  grants: Array<{
    action: string
    resource?: string
    effect?: "allow" | "deny"
    conditions?: object[]
  }>
  id?: string
  name: string
  slug: string
  type: string
  expires_at?: string // date-time
  organization_id?: string
}

Error

Error response

type Error = {
  message: string
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.