Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

2.4 KB
Raw Blame
/*
 * Copyright 2025 Daytona Platforms Inc.
 * Modified by BoxLite AI, 2025-2026
 * SPDX-License-Identifier: AGPL-3.0
 */

/*
  IMPORTANT: When adding a new permission, make sure to update apps/dashboard/src/constants/CreateApiKeyPermissionsGroups.ts accordingly
*/
export enum OrganizationResourcePermission {
  // private registry credentials (read is appended below)
  WRITE_REGISTRIES = 'write:registries',
  DELETE_REGISTRIES = 'delete:registries',

  // templates
  WRITE_TEMPLATES = 'write:templates',
  DELETE_TEMPLATES = 'delete:templates',

  // boxes
  WRITE_BOXES = 'write:boxes',
  DELETE_BOXES = 'delete:boxes',

  // volumes
  READ_VOLUMES = 'read:volumes',
  WRITE_VOLUMES = 'write:volumes',
  DELETE_VOLUMES = 'delete:volumes',

  // regions
  WRITE_REGIONS = 'write:regions',
  DELETE_REGIONS = 'delete:regions',

  // runners
  READ_RUNNERS = 'read:runners',
  WRITE_RUNNERS = 'write:runners',
  DELETE_RUNNERS = 'delete:runners',

  // audit
  READ_AUDIT_LOGS = 'read:audit_logs',

  // images — appended rather than grouped with boxes so this order matches the
  // Postgres enums', which `ALTER TYPE ... ADD VALUE` can only append to.
  READ_IMAGES = 'read:images',
  DELETE_IMAGES = 'delete:images',

  // Appended for the same reason. The write and delete scopes above date from
  // the baseline; this one joins them with the routes that enforce all three,
  // and what it reads carries no password.
  READ_REGISTRIES = 'read:registries',

  // Appended for the same reason, apart from the other image scopes. Using an
  // image still records it without this; what it guards is alias creation and deletion.
  WRITE_IMAGES = 'write:images',

  // Tenant membership, invitations and key revocation; appended to match the database enums.
  READ_MEMBERS = 'read:members',
  WRITE_MEMBERS = 'write:members',
  READ_APPS = 'read:apps',
  WRITE_APPS = 'write:apps',
  DELETE_APPS = 'delete:apps',
  WRITE_SECRETS = 'write:secrets',
  READ_SECRETS = 'read:secrets',
}

export const APP_HOSTING_PERMISSIONS = [
  OrganizationResourcePermission.READ_APPS,
  OrganizationResourcePermission.WRITE_APPS,
  OrganizationResourcePermission.DELETE_APPS,
]

export function organizationAllowsPermission(
  permission: OrganizationResourcePermission,
  enabled: OrganizationResourcePermission[] = [],
): boolean {
  return !APP_HOSTING_PERMISSIONS.includes(permission) || enabled.includes(permission)
}