@decaf-ts/integrations 0.11.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -0
- package/dist/integrations.cjs +1 -1
- package/dist/integrations.cjs.map +1 -1
- package/dist/integrations.js +1 -1
- package/dist/integrations.js.map +1 -1
- package/docker/mailpit-compose.yml +17 -0
- package/docker/postgres-compose.yml +26 -0
- package/lib/cjs/blob/azure/AzureBlobStoreService.cjs +12 -23
- package/lib/cjs/blob/azure/AzureBlobStoreService.cjs.map +1 -1
- package/lib/cjs/blob/core/BlobStoreService.cjs +26 -25
- package/lib/cjs/blob/core/BlobStoreService.cjs.map +1 -1
- package/lib/cjs/blob/gcp/GcsBlobStoreService.cjs +12 -23
- package/lib/cjs/blob/gcp/GcsBlobStoreService.cjs.map +1 -1
- package/lib/cjs/blob/s3/S3BlobStoreService.cjs +11 -16
- package/lib/cjs/blob/s3/S3BlobStoreService.cjs.map +1 -1
- package/lib/cjs/blob/s3/S3CompatibleBlobStoreService.cjs +14 -16
- package/lib/cjs/blob/s3/S3CompatibleBlobStoreService.cjs.map +1 -1
- package/lib/cjs/calendar/environment.cjs +48 -0
- package/lib/cjs/calendar/environment.cjs.map +1 -0
- package/lib/cjs/calendar/google-calendar/GoogleCalendarService.cjs +338 -0
- package/lib/cjs/calendar/google-calendar/GoogleCalendarService.cjs.map +1 -0
- package/lib/cjs/calendar/google-calendar/index.cjs +20 -0
- package/lib/cjs/calendar/google-calendar/index.cjs.map +1 -0
- package/lib/cjs/comms/discord/DiscordService.cjs +318 -0
- package/lib/cjs/comms/discord/DiscordService.cjs.map +1 -0
- package/lib/cjs/comms/discord/index.cjs +19 -0
- package/lib/cjs/comms/discord/index.cjs.map +1 -0
- package/lib/cjs/comms/email/EmailService.cjs +376 -0
- package/lib/cjs/comms/email/EmailService.cjs.map +1 -0
- package/lib/cjs/comms/email/index.cjs +29 -0
- package/lib/cjs/comms/email/index.cjs.map +1 -0
- package/lib/cjs/comms/email/mime.cjs +225 -0
- package/lib/cjs/comms/email/mime.cjs.map +1 -0
- package/lib/cjs/comms/email/smtp.cjs +204 -0
- package/lib/cjs/comms/email/smtp.cjs.map +1 -0
- package/lib/cjs/comms/environment.cjs +79 -0
- package/lib/cjs/comms/environment.cjs.map +1 -0
- package/lib/cjs/comms/gmail/GmailService.cjs +235 -0
- package/lib/cjs/comms/gmail/GmailService.cjs.map +1 -0
- package/lib/cjs/comms/gmail/index.cjs +24 -0
- package/lib/cjs/comms/gmail/index.cjs.map +1 -0
- package/lib/cjs/comms/index.cjs +34 -0
- package/lib/cjs/comms/index.cjs.map +1 -0
- package/lib/cjs/comms/outlook/MicrosoftOutlookService.cjs +325 -0
- package/lib/cjs/comms/outlook/MicrosoftOutlookService.cjs.map +1 -0
- package/lib/cjs/comms/outlook/index.cjs +19 -0
- package/lib/cjs/comms/outlook/index.cjs.map +1 -0
- package/lib/cjs/comms/slack/SlackService.cjs +264 -0
- package/lib/cjs/comms/slack/SlackService.cjs.map +1 -0
- package/lib/cjs/comms/slack/index.cjs +24 -0
- package/lib/cjs/comms/slack/index.cjs.map +1 -0
- package/lib/cjs/comms/teams/TeamsService.cjs +212 -0
- package/lib/cjs/comms/teams/TeamsService.cjs.map +1 -0
- package/lib/cjs/comms/teams/index.cjs +24 -0
- package/lib/cjs/comms/teams/index.cjs.map +1 -0
- package/lib/cjs/comms/telegram/TelegramService.cjs +196 -0
- package/lib/cjs/comms/telegram/TelegramService.cjs.map +1 -0
- package/lib/cjs/comms/telegram/index.cjs +24 -0
- package/lib/cjs/comms/telegram/index.cjs.map +1 -0
- package/lib/cjs/comms/whatsapp/WhatsAppService.cjs +274 -0
- package/lib/cjs/comms/whatsapp/WhatsAppService.cjs.map +1 -0
- package/lib/cjs/comms/whatsapp/index.cjs +19 -0
- package/lib/cjs/comms/whatsapp/index.cjs.map +1 -0
- package/lib/cjs/devops/environment.cjs +43 -0
- package/lib/cjs/devops/environment.cjs.map +1 -0
- package/lib/cjs/devops/github/GithubService.cjs +302 -0
- package/lib/cjs/devops/github/GithubService.cjs.map +1 -0
- package/lib/cjs/devops/github/index.cjs +24 -0
- package/lib/cjs/devops/github/index.cjs.map +1 -0
- package/lib/cjs/devops/gitlab/GitlabService.cjs +282 -0
- package/lib/cjs/devops/gitlab/GitlabService.cjs.map +1 -0
- package/lib/cjs/devops/gitlab/index.cjs +24 -0
- package/lib/cjs/devops/gitlab/index.cjs.map +1 -0
- package/lib/cjs/devops/index.cjs +28 -0
- package/lib/cjs/devops/index.cjs.map +1 -0
- package/lib/cjs/feature-flags/models/FeatureFlag.model.cjs +2 -0
- package/lib/cjs/feature-flags/models/FeatureFlag.model.cjs.map +1 -1
- package/lib/cjs/feature-flags/models/FeatureFlagAccess.model.cjs +2 -0
- package/lib/cjs/feature-flags/models/FeatureFlagAccess.model.cjs.map +1 -1
- package/lib/cjs/index.cjs +3 -3
- package/lib/cjs/io/airtable/AirtableService.cjs +266 -0
- package/lib/cjs/io/airtable/AirtableService.cjs.map +1 -0
- package/lib/cjs/io/airtable/index.cjs +24 -0
- package/lib/cjs/io/airtable/index.cjs.map +1 -0
- package/lib/cjs/io/confluence/ConfluenceService.cjs +317 -0
- package/lib/cjs/io/confluence/ConfluenceService.cjs.map +1 -0
- package/lib/cjs/io/confluence/index.cjs +19 -0
- package/lib/cjs/io/confluence/index.cjs.map +1 -0
- package/lib/cjs/io/environment.cjs +74 -0
- package/lib/cjs/io/environment.cjs.map +1 -0
- package/lib/cjs/io/google-docs/GoogleDocsService.cjs +275 -0
- package/lib/cjs/io/google-docs/GoogleDocsService.cjs.map +1 -0
- package/lib/cjs/io/google-docs/index.cjs +19 -0
- package/lib/cjs/io/google-docs/index.cjs.map +1 -0
- package/lib/cjs/io/google-sheets/GoogleSheetsService.cjs +288 -0
- package/lib/cjs/io/google-sheets/GoogleSheetsService.cjs.map +1 -0
- package/lib/cjs/io/google-sheets/index.cjs +24 -0
- package/lib/cjs/io/google-sheets/index.cjs.map +1 -0
- package/lib/cjs/io/graphql/GraphqlService.cjs +143 -0
- package/lib/cjs/io/graphql/GraphqlService.cjs.map +1 -0
- package/lib/cjs/io/graphql/index.cjs +24 -0
- package/lib/cjs/io/graphql/index.cjs.map +1 -0
- package/lib/cjs/io/index.cjs +35 -0
- package/lib/cjs/io/index.cjs.map +1 -0
- package/lib/cjs/io/jira/JiraService.cjs +354 -0
- package/lib/cjs/io/jira/JiraService.cjs.map +1 -0
- package/lib/cjs/io/jira/index.cjs +19 -0
- package/lib/cjs/io/jira/index.cjs.map +1 -0
- package/lib/cjs/io/microsoft-excel/MicrosoftExcelService.cjs +253 -0
- package/lib/cjs/io/microsoft-excel/MicrosoftExcelService.cjs.map +1 -0
- package/lib/cjs/io/microsoft-excel/index.cjs +19 -0
- package/lib/cjs/io/microsoft-excel/index.cjs.map +1 -0
- package/lib/cjs/io/microsoft-sharepoint/MicrosoftSharePointService.cjs +261 -0
- package/lib/cjs/io/microsoft-sharepoint/MicrosoftSharePointService.cjs.map +1 -0
- package/lib/cjs/io/microsoft-sharepoint/index.cjs +19 -0
- package/lib/cjs/io/microsoft-sharepoint/index.cjs.map +1 -0
- package/lib/cjs/io/spreadsheet/SpreadsheetService.cjs +205 -0
- package/lib/cjs/io/spreadsheet/SpreadsheetService.cjs.map +1 -0
- package/lib/cjs/io/spreadsheet/index.cjs +25 -0
- package/lib/cjs/io/spreadsheet/index.cjs.map +1 -0
- package/lib/cjs/namespaces/index.cjs +1 -0
- package/lib/cjs/namespaces/index.cjs.map +1 -1
- package/lib/cjs/namespaces/models/credential.model.cjs +115 -0
- package/lib/cjs/namespaces/models/credential.model.cjs.map +1 -0
- package/lib/cjs/namespaces/models/effective-permission.model.cjs +2 -0
- package/lib/cjs/namespaces/models/effective-permission.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/group-membership.model.cjs +2 -0
- package/lib/cjs/namespaces/models/group-membership.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/group.model.cjs +2 -0
- package/lib/cjs/namespaces/models/group.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/index.cjs +1 -0
- package/lib/cjs/namespaces/models/index.cjs.map +1 -1
- package/lib/cjs/namespaces/models/inheritance-block.model.cjs +2 -0
- package/lib/cjs/namespaces/models/inheritance-block.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/org-unit-closure.model.cjs +2 -0
- package/lib/cjs/namespaces/models/org-unit-closure.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/org-unit-membership.model.cjs +2 -0
- package/lib/cjs/namespaces/models/org-unit-membership.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/org-unit-profile.model.cjs +2 -0
- package/lib/cjs/namespaces/models/org-unit-profile.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/org-unit.model.cjs +2 -0
- package/lib/cjs/namespaces/models/org-unit.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/permission.model.cjs +2 -0
- package/lib/cjs/namespaces/models/permission.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/principal.model.cjs +2 -0
- package/lib/cjs/namespaces/models/principal.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/protected-resource.model.cjs +2 -0
- package/lib/cjs/namespaces/models/protected-resource.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/resource-grant.model.cjs +2 -0
- package/lib/cjs/namespaces/models/resource-grant.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/role-assignment.model.cjs +2 -0
- package/lib/cjs/namespaces/models/role-assignment.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/role-permission.model.cjs +2 -0
- package/lib/cjs/namespaces/models/role-permission.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/role.model.cjs +2 -0
- package/lib/cjs/namespaces/models/role.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/storage-binding.model.cjs +2 -0
- package/lib/cjs/namespaces/models/storage-binding.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/tenant-membership.model.cjs +2 -0
- package/lib/cjs/namespaces/models/tenant-membership.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/tenant-profile.model.cjs +2 -0
- package/lib/cjs/namespaces/models/tenant-profile.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/tenant.model.cjs +2 -0
- package/lib/cjs/namespaces/models/tenant.model.cjs.map +1 -1
- package/lib/cjs/namespaces/models/user.model.cjs +2 -0
- package/lib/cjs/namespaces/models/user.model.cjs.map +1 -1
- package/lib/cjs/namespaces/rls/index.cjs +28 -0
- package/lib/cjs/namespaces/rls/index.cjs.map +1 -0
- package/lib/cjs/namespaces/rls/principal-resolver.cjs +66 -0
- package/lib/cjs/namespaces/rls/principal-resolver.cjs.map +1 -0
- package/lib/cjs/namespaces/rls/rls-bootstrap.service.cjs +269 -0
- package/lib/cjs/namespaces/rls/rls-bootstrap.service.cjs.map +1 -0
- package/lib/cjs/namespaces/rls/rls.constants.cjs +79 -0
- package/lib/cjs/namespaces/rls/rls.constants.cjs.map +1 -0
- package/lib/cjs/namespaces/rls/rls.template.cjs +719 -0
- package/lib/cjs/namespaces/rls/rls.template.cjs.map +1 -0
- package/lib/cjs/namespaces/rls/rls.types.cjs +4 -0
- package/lib/cjs/namespaces/rls/rls.types.cjs.map +1 -0
- package/lib/cjs/namespaces/rls/session-binding.cjs +70 -0
- package/lib/cjs/namespaces/rls/session-binding.cjs.map +1 -0
- package/lib/cjs/namespaces/services/credential.service.cjs +327 -0
- package/lib/cjs/namespaces/services/credential.service.cjs.map +1 -0
- package/lib/cjs/namespaces/services/index.cjs +1 -0
- package/lib/cjs/namespaces/services/index.cjs.map +1 -1
- package/lib/cjs/namespaces/types.cjs +6 -1
- package/lib/cjs/namespaces/types.cjs.map +1 -1
- package/lib/cjs/redis/adapter.cjs +7 -1
- package/lib/cjs/redis/adapter.cjs.map +1 -1
- package/lib/cjs/secrets/InfraCredentialBootstrap.cjs +80 -0
- package/lib/cjs/secrets/InfraCredentialBootstrap.cjs.map +1 -0
- package/lib/cjs/secrets/aws/AwsSecretService.cjs +2 -15
- package/lib/cjs/secrets/aws/AwsSecretService.cjs.map +1 -1
- package/lib/cjs/secrets/azure/AzureKeyVaultSecretService.cjs +2 -16
- package/lib/cjs/secrets/azure/AzureKeyVaultSecretService.cjs.map +1 -1
- package/lib/cjs/secrets/core/SecretReference.cjs +1 -0
- package/lib/cjs/secrets/core/SecretReference.cjs.map +1 -1
- package/lib/cjs/secrets/fs/FsSecretEnvironment.cjs +28 -0
- package/lib/cjs/secrets/fs/FsSecretEnvironment.cjs.map +1 -0
- package/lib/cjs/secrets/fs/FsSecretService.cjs +420 -0
- package/lib/cjs/secrets/fs/FsSecretService.cjs.map +1 -0
- package/lib/cjs/secrets/fs/FsSecretServiceConfig.cjs +25 -0
- package/lib/cjs/secrets/fs/FsSecretServiceConfig.cjs.map +1 -0
- package/lib/cjs/secrets/fs/index.cjs +27 -0
- package/lib/cjs/secrets/fs/index.cjs.map +1 -0
- package/lib/cjs/secrets/gcp/GcpSecretManagerService.cjs +2 -16
- package/lib/cjs/secrets/gcp/GcpSecretManagerService.cjs.map +1 -1
- package/lib/cjs/secrets/index.cjs +2 -0
- package/lib/cjs/secrets/index.cjs.map +1 -1
- package/lib/cjs/secrets/model/ModelSecretService.cjs +335 -43
- package/lib/cjs/secrets/model/ModelSecretService.cjs.map +1 -1
- package/lib/cjs/secrets/model/Secret.cjs +83 -5
- package/lib/cjs/secrets/model/Secret.cjs.map +1 -1
- package/lib/cjs/secrets/onepassword/OnePasswordSecretService.cjs +2 -16
- package/lib/cjs/secrets/onepassword/OnePasswordSecretService.cjs.map +1 -1
- package/lib/cjs/secrets/vault/VaultSecretService.cjs +2 -16
- package/lib/cjs/secrets/vault/VaultSecretService.cjs.map +1 -1
- package/lib/cjs/shared/environmentValue.cjs +24 -0
- package/lib/cjs/shared/environmentValue.cjs.map +1 -1
- package/lib/cjs/shared/http/HttpApiService.cjs +190 -0
- package/lib/cjs/shared/http/HttpApiService.cjs.map +1 -0
- package/lib/cjs/shared/http/hermeticBoot.cjs +150 -0
- package/lib/cjs/shared/http/hermeticBoot.cjs.map +1 -0
- package/lib/cjs/shared/http/index.cjs +28 -0
- package/lib/cjs/shared/http/index.cjs.map +1 -0
- package/lib/esm/blob/azure/AzureBlobStoreService.js +13 -21
- package/lib/esm/blob/azure/AzureBlobStoreService.js.map +1 -1
- package/lib/esm/blob/core/BlobStoreService.js +26 -25
- package/lib/esm/blob/core/BlobStoreService.js.map +1 -1
- package/lib/esm/blob/gcp/GcsBlobStoreService.js +13 -21
- package/lib/esm/blob/gcp/GcsBlobStoreService.js.map +1 -1
- package/lib/esm/blob/s3/S3BlobStoreService.js +12 -14
- package/lib/esm/blob/s3/S3BlobStoreService.js.map +1 -1
- package/lib/esm/blob/s3/S3CompatibleBlobStoreService.js +14 -16
- package/lib/esm/blob/s3/S3CompatibleBlobStoreService.js.map +1 -1
- package/lib/esm/calendar/environment.js +44 -0
- package/lib/esm/calendar/environment.js.map +1 -0
- package/lib/esm/calendar/google-calendar/GoogleCalendarService.js +333 -0
- package/lib/esm/calendar/google-calendar/GoogleCalendarService.js.map +1 -0
- package/lib/esm/calendar/google-calendar/index.js +3 -0
- package/lib/esm/calendar/google-calendar/index.js.map +1 -0
- package/lib/esm/comms/discord/DiscordService.js +313 -0
- package/lib/esm/comms/discord/DiscordService.js.map +1 -0
- package/lib/esm/comms/discord/index.js +2 -0
- package/lib/esm/comms/discord/index.js.map +1 -0
- package/lib/esm/comms/email/EmailService.js +338 -0
- package/lib/esm/comms/email/EmailService.js.map +1 -0
- package/lib/esm/comms/email/index.js +12 -0
- package/lib/esm/comms/email/index.js.map +1 -0
- package/lib/esm/comms/email/mime.js +218 -0
- package/lib/esm/comms/email/mime.js.map +1 -0
- package/lib/esm/comms/email/smtp.js +166 -0
- package/lib/esm/comms/email/smtp.js.map +1 -0
- package/lib/esm/comms/environment.js +75 -0
- package/lib/esm/comms/environment.js.map +1 -0
- package/lib/esm/comms/gmail/GmailService.js +230 -0
- package/lib/esm/comms/gmail/GmailService.js.map +1 -0
- package/lib/esm/comms/gmail/index.js +7 -0
- package/lib/esm/comms/gmail/index.js.map +1 -0
- package/lib/esm/comms/index.js +17 -0
- package/lib/esm/comms/index.js.map +1 -0
- package/lib/esm/comms/outlook/MicrosoftOutlookService.js +320 -0
- package/lib/esm/comms/outlook/MicrosoftOutlookService.js.map +1 -0
- package/lib/esm/comms/outlook/index.js +2 -0
- package/lib/esm/comms/outlook/index.js.map +1 -0
- package/lib/esm/comms/slack/SlackService.js +259 -0
- package/lib/esm/comms/slack/SlackService.js.map +1 -0
- package/lib/esm/comms/slack/index.js +7 -0
- package/lib/esm/comms/slack/index.js.map +1 -0
- package/lib/esm/comms/teams/TeamsService.js +204 -0
- package/lib/esm/comms/teams/TeamsService.js.map +1 -0
- package/lib/esm/comms/teams/index.js +7 -0
- package/lib/esm/comms/teams/index.js.map +1 -0
- package/lib/esm/comms/telegram/TelegramService.js +191 -0
- package/lib/esm/comms/telegram/TelegramService.js.map +1 -0
- package/lib/esm/comms/telegram/index.js +7 -0
- package/lib/esm/comms/telegram/index.js.map +1 -0
- package/lib/esm/comms/whatsapp/WhatsAppService.js +269 -0
- package/lib/esm/comms/whatsapp/WhatsAppService.js.map +1 -0
- package/lib/esm/comms/whatsapp/index.js +2 -0
- package/lib/esm/comms/whatsapp/index.js.map +1 -0
- package/lib/esm/devops/environment.js +39 -0
- package/lib/esm/devops/environment.js.map +1 -0
- package/lib/esm/devops/github/GithubService.js +297 -0
- package/lib/esm/devops/github/GithubService.js.map +1 -0
- package/lib/esm/devops/github/index.js +7 -0
- package/lib/esm/devops/github/index.js.map +1 -0
- package/lib/esm/devops/gitlab/GitlabService.js +277 -0
- package/lib/esm/devops/gitlab/GitlabService.js.map +1 -0
- package/lib/esm/devops/gitlab/index.js +7 -0
- package/lib/esm/devops/gitlab/index.js.map +1 -0
- package/lib/esm/devops/index.js +11 -0
- package/lib/esm/devops/index.js.map +1 -0
- package/lib/esm/feature-flags/models/FeatureFlag.model.js +2 -0
- package/lib/esm/feature-flags/models/FeatureFlag.model.js.map +1 -1
- package/lib/esm/feature-flags/models/FeatureFlagAccess.model.js +2 -0
- package/lib/esm/feature-flags/models/FeatureFlagAccess.model.js.map +1 -1
- package/lib/esm/index.js +3 -3
- package/lib/esm/io/airtable/AirtableService.js +261 -0
- package/lib/esm/io/airtable/AirtableService.js.map +1 -0
- package/lib/esm/io/airtable/index.js +7 -0
- package/lib/esm/io/airtable/index.js.map +1 -0
- package/lib/esm/io/confluence/ConfluenceService.js +312 -0
- package/lib/esm/io/confluence/ConfluenceService.js.map +1 -0
- package/lib/esm/io/confluence/index.js +2 -0
- package/lib/esm/io/confluence/index.js.map +1 -0
- package/lib/esm/io/environment.js +70 -0
- package/lib/esm/io/environment.js.map +1 -0
- package/lib/esm/io/google-docs/GoogleDocsService.js +270 -0
- package/lib/esm/io/google-docs/GoogleDocsService.js.map +1 -0
- package/lib/esm/io/google-docs/index.js +2 -0
- package/lib/esm/io/google-docs/index.js.map +1 -0
- package/lib/esm/io/google-sheets/GoogleSheetsService.js +283 -0
- package/lib/esm/io/google-sheets/GoogleSheetsService.js.map +1 -0
- package/lib/esm/io/google-sheets/index.js +7 -0
- package/lib/esm/io/google-sheets/index.js.map +1 -0
- package/lib/esm/io/graphql/GraphqlService.js +138 -0
- package/lib/esm/io/graphql/GraphqlService.js.map +1 -0
- package/lib/esm/io/graphql/index.js +7 -0
- package/lib/esm/io/graphql/index.js.map +1 -0
- package/lib/esm/io/index.js +18 -0
- package/lib/esm/io/index.js.map +1 -0
- package/lib/esm/io/jira/JiraService.js +349 -0
- package/lib/esm/io/jira/JiraService.js.map +1 -0
- package/lib/esm/io/jira/index.js +2 -0
- package/lib/esm/io/jira/index.js.map +1 -0
- package/lib/esm/io/microsoft-excel/MicrosoftExcelService.js +248 -0
- package/lib/esm/io/microsoft-excel/MicrosoftExcelService.js.map +1 -0
- package/lib/esm/io/microsoft-excel/index.js +2 -0
- package/lib/esm/io/microsoft-excel/index.js.map +1 -0
- package/lib/esm/io/microsoft-sharepoint/MicrosoftSharePointService.js +256 -0
- package/lib/esm/io/microsoft-sharepoint/MicrosoftSharePointService.js.map +1 -0
- package/lib/esm/io/microsoft-sharepoint/index.js +2 -0
- package/lib/esm/io/microsoft-sharepoint/index.js.map +1 -0
- package/lib/esm/io/spreadsheet/SpreadsheetService.js +200 -0
- package/lib/esm/io/spreadsheet/SpreadsheetService.js.map +1 -0
- package/lib/esm/io/spreadsheet/index.js +8 -0
- package/lib/esm/io/spreadsheet/index.js.map +1 -0
- package/lib/esm/namespaces/index.js +1 -0
- package/lib/esm/namespaces/index.js.map +1 -1
- package/lib/esm/namespaces/models/credential.model.js +106 -0
- package/lib/esm/namespaces/models/credential.model.js.map +1 -0
- package/lib/esm/namespaces/models/effective-permission.model.js +2 -0
- package/lib/esm/namespaces/models/effective-permission.model.js.map +1 -1
- package/lib/esm/namespaces/models/group-membership.model.js +2 -0
- package/lib/esm/namespaces/models/group-membership.model.js.map +1 -1
- package/lib/esm/namespaces/models/group.model.js +2 -0
- package/lib/esm/namespaces/models/group.model.js.map +1 -1
- package/lib/esm/namespaces/models/index.js +1 -0
- package/lib/esm/namespaces/models/index.js.map +1 -1
- package/lib/esm/namespaces/models/inheritance-block.model.js +2 -0
- package/lib/esm/namespaces/models/inheritance-block.model.js.map +1 -1
- package/lib/esm/namespaces/models/org-unit-closure.model.js +2 -0
- package/lib/esm/namespaces/models/org-unit-closure.model.js.map +1 -1
- package/lib/esm/namespaces/models/org-unit-membership.model.js +2 -0
- package/lib/esm/namespaces/models/org-unit-membership.model.js.map +1 -1
- package/lib/esm/namespaces/models/org-unit-profile.model.js +2 -0
- package/lib/esm/namespaces/models/org-unit-profile.model.js.map +1 -1
- package/lib/esm/namespaces/models/org-unit.model.js +2 -0
- package/lib/esm/namespaces/models/org-unit.model.js.map +1 -1
- package/lib/esm/namespaces/models/permission.model.js +2 -0
- package/lib/esm/namespaces/models/permission.model.js.map +1 -1
- package/lib/esm/namespaces/models/principal.model.js +2 -0
- package/lib/esm/namespaces/models/principal.model.js.map +1 -1
- package/lib/esm/namespaces/models/protected-resource.model.js +2 -0
- package/lib/esm/namespaces/models/protected-resource.model.js.map +1 -1
- package/lib/esm/namespaces/models/resource-grant.model.js +2 -0
- package/lib/esm/namespaces/models/resource-grant.model.js.map +1 -1
- package/lib/esm/namespaces/models/role-assignment.model.js +2 -0
- package/lib/esm/namespaces/models/role-assignment.model.js.map +1 -1
- package/lib/esm/namespaces/models/role-permission.model.js +2 -0
- package/lib/esm/namespaces/models/role-permission.model.js.map +1 -1
- package/lib/esm/namespaces/models/role.model.js +2 -0
- package/lib/esm/namespaces/models/role.model.js.map +1 -1
- package/lib/esm/namespaces/models/storage-binding.model.js +2 -0
- package/lib/esm/namespaces/models/storage-binding.model.js.map +1 -1
- package/lib/esm/namespaces/models/tenant-membership.model.js +2 -0
- package/lib/esm/namespaces/models/tenant-membership.model.js.map +1 -1
- package/lib/esm/namespaces/models/tenant-profile.model.js +2 -0
- package/lib/esm/namespaces/models/tenant-profile.model.js.map +1 -1
- package/lib/esm/namespaces/models/tenant.model.js +2 -0
- package/lib/esm/namespaces/models/tenant.model.js.map +1 -1
- package/lib/esm/namespaces/models/user.model.js +2 -0
- package/lib/esm/namespaces/models/user.model.js.map +1 -1
- package/lib/esm/namespaces/rls/index.js +11 -0
- package/lib/esm/namespaces/rls/index.js.map +1 -0
- package/lib/esm/namespaces/rls/principal-resolver.js +61 -0
- package/lib/esm/namespaces/rls/principal-resolver.js.map +1 -0
- package/lib/esm/namespaces/rls/rls-bootstrap.service.js +261 -0
- package/lib/esm/namespaces/rls/rls-bootstrap.service.js.map +1 -0
- package/lib/esm/namespaces/rls/rls.constants.js +75 -0
- package/lib/esm/namespaces/rls/rls.constants.js.map +1 -0
- package/lib/esm/namespaces/rls/rls.template.js +711 -0
- package/lib/esm/namespaces/rls/rls.template.js.map +1 -0
- package/lib/esm/namespaces/rls/rls.types.js +9 -0
- package/lib/esm/namespaces/rls/rls.types.js.map +1 -0
- package/lib/esm/namespaces/rls/session-binding.js +65 -0
- package/lib/esm/namespaces/rls/session-binding.js.map +1 -0
- package/lib/esm/namespaces/services/credential.service.js +322 -0
- package/lib/esm/namespaces/services/credential.service.js.map +1 -0
- package/lib/esm/namespaces/services/index.js +1 -0
- package/lib/esm/namespaces/services/index.js.map +1 -1
- package/lib/esm/namespaces/types.js +6 -0
- package/lib/esm/namespaces/types.js.map +1 -1
- package/lib/esm/redis/adapter.js +7 -1
- package/lib/esm/redis/adapter.js.map +1 -1
- package/lib/esm/secrets/InfraCredentialBootstrap.js +74 -0
- package/lib/esm/secrets/InfraCredentialBootstrap.js.map +1 -0
- package/lib/esm/secrets/aws/AwsSecretService.js +3 -13
- package/lib/esm/secrets/aws/AwsSecretService.js.map +1 -1
- package/lib/esm/secrets/azure/AzureKeyVaultSecretService.js +2 -13
- package/lib/esm/secrets/azure/AzureKeyVaultSecretService.js.map +1 -1
- package/lib/esm/secrets/core/SecretReference.js +1 -0
- package/lib/esm/secrets/core/SecretReference.js.map +1 -1
- package/lib/esm/secrets/fs/FsSecretEnvironment.js +24 -0
- package/lib/esm/secrets/fs/FsSecretEnvironment.js.map +1 -0
- package/lib/esm/secrets/fs/FsSecretService.js +412 -0
- package/lib/esm/secrets/fs/FsSecretService.js.map +1 -0
- package/lib/esm/secrets/fs/FsSecretServiceConfig.js +21 -0
- package/lib/esm/secrets/fs/FsSecretServiceConfig.js.map +1 -0
- package/lib/esm/secrets/fs/index.js +10 -0
- package/lib/esm/secrets/fs/index.js.map +1 -0
- package/lib/esm/secrets/gcp/GcpSecretManagerService.js +2 -13
- package/lib/esm/secrets/gcp/GcpSecretManagerService.js.map +1 -1
- package/lib/esm/secrets/index.js +2 -0
- package/lib/esm/secrets/index.js.map +1 -1
- package/lib/esm/secrets/model/ModelSecretService.js +337 -42
- package/lib/esm/secrets/model/ModelSecretService.js.map +1 -1
- package/lib/esm/secrets/model/Secret.js +86 -7
- package/lib/esm/secrets/model/Secret.js.map +1 -1
- package/lib/esm/secrets/onepassword/OnePasswordSecretService.js +2 -13
- package/lib/esm/secrets/onepassword/OnePasswordSecretService.js.map +1 -1
- package/lib/esm/secrets/vault/VaultSecretService.js +2 -13
- package/lib/esm/secrets/vault/VaultSecretService.js.map +1 -1
- package/lib/esm/shared/environmentValue.js +24 -0
- package/lib/esm/shared/environmentValue.js.map +1 -1
- package/lib/esm/shared/http/HttpApiService.js +181 -0
- package/lib/esm/shared/http/HttpApiService.js.map +1 -0
- package/lib/esm/shared/http/hermeticBoot.js +146 -0
- package/lib/esm/shared/http/hermeticBoot.js.map +1 -0
- package/lib/esm/shared/http/index.js +11 -0
- package/lib/esm/shared/http/index.js.map +1 -0
- package/lib/types/blob/azure/AzureBlobStoreService.d.cts +7 -7
- package/lib/types/blob/azure/AzureBlobStoreService.d.mts +7 -7
- package/lib/types/blob/core/BlobStoreService.d.cts +28 -27
- package/lib/types/blob/core/BlobStoreService.d.mts +28 -27
- package/lib/types/blob/gcp/GcsBlobStoreService.d.cts +7 -7
- package/lib/types/blob/gcp/GcsBlobStoreService.d.mts +7 -7
- package/lib/types/blob/s3/S3BlobStoreService.d.cts +9 -1
- package/lib/types/blob/s3/S3BlobStoreService.d.mts +9 -1
- package/lib/types/blob/s3/S3CompatibleBlobStoreService.d.cts +11 -15
- package/lib/types/blob/s3/S3CompatibleBlobStoreService.d.mts +11 -15
- package/lib/types/calendar/environment.d.cts +48 -0
- package/lib/types/calendar/environment.d.mts +48 -0
- package/lib/types/calendar/google-calendar/GoogleCalendarService.d.cts +316 -0
- package/lib/types/calendar/google-calendar/GoogleCalendarService.d.mts +316 -0
- package/lib/types/calendar/google-calendar/index.d.cts +2 -0
- package/lib/types/calendar/google-calendar/index.d.mts +2 -0
- package/lib/types/comms/discord/DiscordService.d.cts +285 -0
- package/lib/types/comms/discord/DiscordService.d.mts +285 -0
- package/lib/types/comms/discord/index.d.cts +1 -0
- package/lib/types/comms/discord/index.d.mts +1 -0
- package/lib/types/comms/email/EmailService.d.cts +184 -0
- package/lib/types/comms/email/EmailService.d.mts +184 -0
- package/lib/types/comms/email/index.d.cts +11 -0
- package/lib/types/comms/email/index.d.mts +11 -0
- package/lib/types/comms/email/mime.d.cts +84 -0
- package/lib/types/comms/email/mime.d.mts +84 -0
- package/lib/types/comms/email/smtp.d.cts +107 -0
- package/lib/types/comms/email/smtp.d.mts +107 -0
- package/lib/types/comms/environment.d.cts +110 -0
- package/lib/types/comms/environment.d.mts +110 -0
- package/lib/types/comms/gmail/GmailService.d.cts +190 -0
- package/lib/types/comms/gmail/GmailService.d.mts +190 -0
- package/lib/types/comms/gmail/index.d.cts +6 -0
- package/lib/types/comms/gmail/index.d.mts +6 -0
- package/lib/types/comms/index.d.cts +16 -0
- package/lib/types/comms/index.d.mts +16 -0
- package/lib/types/comms/outlook/MicrosoftOutlookService.d.cts +282 -0
- package/lib/types/comms/outlook/MicrosoftOutlookService.d.mts +282 -0
- package/lib/types/comms/outlook/index.d.cts +1 -0
- package/lib/types/comms/outlook/index.d.mts +1 -0
- package/lib/types/comms/slack/SlackService.d.cts +259 -0
- package/lib/types/comms/slack/SlackService.d.mts +259 -0
- package/lib/types/comms/slack/index.d.cts +6 -0
- package/lib/types/comms/slack/index.d.mts +6 -0
- package/lib/types/comms/teams/TeamsService.d.cts +172 -0
- package/lib/types/comms/teams/TeamsService.d.mts +172 -0
- package/lib/types/comms/teams/index.d.cts +6 -0
- package/lib/types/comms/teams/index.d.mts +6 -0
- package/lib/types/comms/telegram/TelegramService.d.cts +202 -0
- package/lib/types/comms/telegram/TelegramService.d.mts +202 -0
- package/lib/types/comms/telegram/index.d.cts +6 -0
- package/lib/types/comms/telegram/index.d.mts +6 -0
- package/lib/types/comms/whatsapp/WhatsAppService.d.cts +258 -0
- package/lib/types/comms/whatsapp/WhatsAppService.d.mts +258 -0
- package/lib/types/comms/whatsapp/index.d.cts +1 -0
- package/lib/types/comms/whatsapp/index.d.mts +1 -0
- package/lib/types/devops/environment.d.cts +62 -0
- package/lib/types/devops/environment.d.mts +62 -0
- package/lib/types/devops/github/GithubService.d.cts +287 -0
- package/lib/types/devops/github/GithubService.d.mts +287 -0
- package/lib/types/devops/github/index.d.cts +6 -0
- package/lib/types/devops/github/index.d.mts +6 -0
- package/lib/types/devops/gitlab/GitlabService.d.cts +277 -0
- package/lib/types/devops/gitlab/GitlabService.d.mts +277 -0
- package/lib/types/devops/gitlab/index.d.cts +6 -0
- package/lib/types/devops/gitlab/index.d.mts +6 -0
- package/lib/types/devops/index.d.cts +10 -0
- package/lib/types/devops/index.d.mts +10 -0
- package/lib/types/index.d.cts +2 -2
- package/lib/types/index.d.mts +2 -2
- package/lib/types/io/airtable/AirtableService.d.cts +268 -0
- package/lib/types/io/airtable/AirtableService.d.mts +268 -0
- package/lib/types/io/airtable/index.d.cts +6 -0
- package/lib/types/io/airtable/index.d.mts +6 -0
- package/lib/types/io/confluence/ConfluenceService.d.cts +250 -0
- package/lib/types/io/confluence/ConfluenceService.d.mts +250 -0
- package/lib/types/io/confluence/index.d.cts +1 -0
- package/lib/types/io/confluence/index.d.mts +1 -0
- package/lib/types/io/environment.d.cts +107 -0
- package/lib/types/io/environment.d.mts +107 -0
- package/lib/types/io/google-docs/GoogleDocsService.d.cts +188 -0
- package/lib/types/io/google-docs/GoogleDocsService.d.mts +188 -0
- package/lib/types/io/google-docs/index.d.cts +1 -0
- package/lib/types/io/google-docs/index.d.mts +1 -0
- package/lib/types/io/google-sheets/GoogleSheetsService.d.cts +204 -0
- package/lib/types/io/google-sheets/GoogleSheetsService.d.mts +204 -0
- package/lib/types/io/google-sheets/index.d.cts +6 -0
- package/lib/types/io/google-sheets/index.d.mts +6 -0
- package/lib/types/io/graphql/GraphqlService.d.cts +173 -0
- package/lib/types/io/graphql/GraphqlService.d.mts +173 -0
- package/lib/types/io/graphql/index.d.cts +6 -0
- package/lib/types/io/graphql/index.d.mts +6 -0
- package/lib/types/io/index.d.cts +17 -0
- package/lib/types/io/index.d.mts +17 -0
- package/lib/types/io/jira/JiraService.d.cts +300 -0
- package/lib/types/io/jira/JiraService.d.mts +300 -0
- package/lib/types/io/jira/index.d.cts +1 -0
- package/lib/types/io/jira/index.d.mts +1 -0
- package/lib/types/io/microsoft-excel/MicrosoftExcelService.d.cts +230 -0
- package/lib/types/io/microsoft-excel/MicrosoftExcelService.d.mts +230 -0
- package/lib/types/io/microsoft-excel/index.d.cts +1 -0
- package/lib/types/io/microsoft-excel/index.d.mts +1 -0
- package/lib/types/io/microsoft-sharepoint/MicrosoftSharePointService.d.cts +226 -0
- package/lib/types/io/microsoft-sharepoint/MicrosoftSharePointService.d.mts +226 -0
- package/lib/types/io/microsoft-sharepoint/index.d.cts +1 -0
- package/lib/types/io/microsoft-sharepoint/index.d.mts +1 -0
- package/lib/types/io/spreadsheet/SpreadsheetService.d.cts +144 -0
- package/lib/types/io/spreadsheet/SpreadsheetService.d.mts +144 -0
- package/lib/types/io/spreadsheet/index.d.cts +7 -0
- package/lib/types/io/spreadsheet/index.d.mts +7 -0
- package/lib/types/namespaces/index.d.cts +1 -0
- package/lib/types/namespaces/index.d.mts +1 -0
- package/lib/types/namespaces/models/credential.model.d.cts +23 -0
- package/lib/types/namespaces/models/credential.model.d.mts +23 -0
- package/lib/types/namespaces/models/index.d.cts +1 -0
- package/lib/types/namespaces/models/index.d.mts +1 -0
- package/lib/types/namespaces/rls/index.d.cts +10 -0
- package/lib/types/namespaces/rls/index.d.mts +10 -0
- package/lib/types/namespaces/rls/principal-resolver.d.cts +47 -0
- package/lib/types/namespaces/rls/principal-resolver.d.mts +47 -0
- package/lib/types/namespaces/rls/rls-bootstrap.service.d.cts +157 -0
- package/lib/types/namespaces/rls/rls-bootstrap.service.d.mts +157 -0
- package/lib/types/namespaces/rls/rls.constants.d.cts +52 -0
- package/lib/types/namespaces/rls/rls.constants.d.mts +52 -0
- package/lib/types/namespaces/rls/rls.template.d.cts +42 -0
- package/lib/types/namespaces/rls/rls.template.d.mts +42 -0
- package/lib/types/namespaces/rls/rls.types.d.cts +77 -0
- package/lib/types/namespaces/rls/rls.types.d.mts +77 -0
- package/lib/types/namespaces/rls/session-binding.d.cts +87 -0
- package/lib/types/namespaces/rls/session-binding.d.mts +87 -0
- package/lib/types/namespaces/services/credential.service.d.cts +175 -0
- package/lib/types/namespaces/services/credential.service.d.mts +175 -0
- package/lib/types/namespaces/services/index.d.cts +1 -0
- package/lib/types/namespaces/services/index.d.mts +1 -0
- package/lib/types/namespaces/types.d.cts +37 -0
- package/lib/types/namespaces/types.d.mts +37 -0
- package/lib/types/redis/adapter.d.cts +2 -0
- package/lib/types/redis/adapter.d.mts +2 -0
- package/lib/types/redis/types.d.cts +27 -2
- package/lib/types/redis/types.d.mts +27 -2
- package/lib/types/secrets/InfraCredentialBootstrap.d.cts +100 -0
- package/lib/types/secrets/InfraCredentialBootstrap.d.mts +100 -0
- package/lib/types/secrets/core/SecretTypes.d.cts +15 -1
- package/lib/types/secrets/core/SecretTypes.d.mts +15 -1
- package/lib/types/secrets/fs/FsSecretEnvironment.d.cts +42 -0
- package/lib/types/secrets/fs/FsSecretEnvironment.d.mts +42 -0
- package/lib/types/secrets/fs/FsSecretService.d.cts +207 -0
- package/lib/types/secrets/fs/FsSecretService.d.mts +207 -0
- package/lib/types/secrets/fs/FsSecretServiceConfig.d.cts +37 -0
- package/lib/types/secrets/fs/FsSecretServiceConfig.d.mts +37 -0
- package/lib/types/secrets/fs/index.d.cts +9 -0
- package/lib/types/secrets/fs/index.d.mts +9 -0
- package/lib/types/secrets/index.d.cts +2 -0
- package/lib/types/secrets/index.d.mts +2 -0
- package/lib/types/secrets/model/ModelSecretService.d.cts +190 -1
- package/lib/types/secrets/model/ModelSecretService.d.mts +190 -1
- package/lib/types/secrets/model/Secret.d.cts +44 -3
- package/lib/types/secrets/model/Secret.d.mts +44 -3
- package/lib/types/shared/environmentValue.d.cts +24 -0
- package/lib/types/shared/environmentValue.d.mts +24 -0
- package/lib/types/shared/http/HttpApiService.d.cts +193 -0
- package/lib/types/shared/http/HttpApiService.d.mts +193 -0
- package/lib/types/shared/http/hermeticBoot.d.cts +84 -0
- package/lib/types/shared/http/hermeticBoot.d.mts +84 -0
- package/lib/types/shared/http/index.d.cts +10 -0
- package/lib/types/shared/http/index.d.mts +10 -0
- package/package.json +279 -6
- package/sql/002_rls.sql +660 -15
- package/sql/004_credentials.sql +46 -0
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NAMESPACE_RLS_POLICY_SETS = exports.RLS_FUNCTION_STATEMENTS = void 0;
|
|
4
|
+
exports.rlsPolicyStatements = rlsPolicyStatements;
|
|
5
|
+
exports.rlsBootstrapStatements = rlsBootstrapStatements;
|
|
6
|
+
exports.rlsPolicyTables = rlsPolicyTables;
|
|
7
|
+
exports.assertRlsTableCoverage = assertRlsTableCoverage;
|
|
8
|
+
/**
|
|
9
|
+
* @module integrations/namespaces/rls/template
|
|
10
|
+
* @summary SQL template for the namespace row-level-security policies.
|
|
11
|
+
* @description Generates the helper functions and enable/force/policy DDL that
|
|
12
|
+
* enforce the reader/writer/admin matrix across the namespace tables and the
|
|
13
|
+
* slice-1 credential/secret records.
|
|
14
|
+
*
|
|
15
|
+
* The template assumes the canonical snake_case schema documented by the
|
|
16
|
+
* `integrations/sql` artifacts. Helper functions are `SECURITY DEFINER` so the
|
|
17
|
+
* authorization lookups bypass RLS and cannot recurse through the policies they
|
|
18
|
+
* implement. Production deployments should own those functions with a role that
|
|
19
|
+
* is allowed to bypass RLS (the database owner, a `BYPASSRLS` role, or the
|
|
20
|
+
* migration role).
|
|
21
|
+
*/
|
|
22
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
23
|
+
const rls_constants_js_1 = require("./rls.constants.cjs");
|
|
24
|
+
const FUNCTION_SEARCH_PATH = "SET search_path = public, pg_temp";
|
|
25
|
+
/**
|
|
26
|
+
* @description Helper functions backing the namespace RLS policies.
|
|
27
|
+
* @summary Each function is idempotently created with `CREATE OR REPLACE`.
|
|
28
|
+
* `app_rls_principal_for_subject(text, uuid)` is additionally `SECURITY
|
|
29
|
+
* DEFINER` with `search_path` pinned to `public, pg_temp` and `REVOKE`d from
|
|
30
|
+
* `PUBLIC`: it maps an authenticated subject (and optional tenant) to the
|
|
31
|
+
* single matching principal UUID - or `NULL` when the match is ambiguous or
|
|
32
|
+
* absent - and is consumed by privileged resolvers such as
|
|
33
|
+
* `resolvePrincipalForSubject` from `./principal-resolver`.
|
|
34
|
+
*/
|
|
35
|
+
exports.RLS_FUNCTION_STATEMENTS = [
|
|
36
|
+
`CREATE OR REPLACE FUNCTION app_rls_principal_id()
|
|
37
|
+
RETURNS uuid
|
|
38
|
+
LANGUAGE sql
|
|
39
|
+
STABLE
|
|
40
|
+
AS $fn$
|
|
41
|
+
SELECT NULLIF(current_setting('${rls_constants_js_1.RLS_SETTINGS.Principal}', true), '')::uuid
|
|
42
|
+
$fn$;`,
|
|
43
|
+
`CREATE OR REPLACE FUNCTION app_rls_subject_id()
|
|
44
|
+
RETURNS text
|
|
45
|
+
LANGUAGE sql
|
|
46
|
+
STABLE
|
|
47
|
+
SECURITY DEFINER
|
|
48
|
+
${FUNCTION_SEARCH_PATH}
|
|
49
|
+
AS $fn$
|
|
50
|
+
SELECT p.subject_id
|
|
51
|
+
FROM principals p
|
|
52
|
+
WHERE p.id = app_rls_principal_id()
|
|
53
|
+
$fn$;`,
|
|
54
|
+
`CREATE OR REPLACE FUNCTION app_rls_principal_for_subject(
|
|
55
|
+
p_subject text,
|
|
56
|
+
p_tenant uuid DEFAULT NULL
|
|
57
|
+
)
|
|
58
|
+
RETURNS uuid
|
|
59
|
+
LANGUAGE sql
|
|
60
|
+
STABLE
|
|
61
|
+
SECURITY DEFINER
|
|
62
|
+
${FUNCTION_SEARCH_PATH}
|
|
63
|
+
AS $fn$
|
|
64
|
+
SELECT CASE WHEN COUNT(*) = 1 THEN (MIN(p.id::text))::uuid ELSE NULL END
|
|
65
|
+
FROM principals p
|
|
66
|
+
WHERE p.subject_id = NULLIF(p_subject, '')
|
|
67
|
+
AND (p_tenant IS NULL OR p.tenant_id = p_tenant)
|
|
68
|
+
$fn$;`,
|
|
69
|
+
`REVOKE ALL ON FUNCTION app_rls_principal_for_subject(text, uuid) FROM PUBLIC;`,
|
|
70
|
+
`CREATE OR REPLACE FUNCTION app_rls_org_unit_tenant(p_org_unit uuid)
|
|
71
|
+
RETURNS uuid
|
|
72
|
+
LANGUAGE sql
|
|
73
|
+
STABLE
|
|
74
|
+
SECURITY DEFINER
|
|
75
|
+
${FUNCTION_SEARCH_PATH}
|
|
76
|
+
AS $fn$
|
|
77
|
+
SELECT ou.tenant_id
|
|
78
|
+
FROM org_units ou
|
|
79
|
+
WHERE ou.id = p_org_unit
|
|
80
|
+
$fn$;`,
|
|
81
|
+
`CREATE OR REPLACE FUNCTION app_rls_has_permission(
|
|
82
|
+
p_tenant uuid,
|
|
83
|
+
p_permission text,
|
|
84
|
+
p_scope_kind text,
|
|
85
|
+
p_scope_id text
|
|
86
|
+
)
|
|
87
|
+
RETURNS boolean
|
|
88
|
+
LANGUAGE sql
|
|
89
|
+
STABLE
|
|
90
|
+
SECURITY DEFINER
|
|
91
|
+
${FUNCTION_SEARCH_PATH}
|
|
92
|
+
AS $fn$
|
|
93
|
+
SELECT EXISTS (
|
|
94
|
+
SELECT 1
|
|
95
|
+
FROM effective_permissions ep
|
|
96
|
+
WHERE ep.tenant_id = p_tenant
|
|
97
|
+
AND ep.principal_id = app_rls_principal_id()
|
|
98
|
+
AND ep.permission_key = p_permission
|
|
99
|
+
AND ep.scope_kind = p_scope_kind
|
|
100
|
+
AND ep.scope_id = p_scope_id
|
|
101
|
+
AND (ep.starts_at IS NULL OR ep.starts_at <= now())
|
|
102
|
+
AND (ep.expires_at IS NULL OR ep.expires_at >= now())
|
|
103
|
+
)
|
|
104
|
+
$fn$;`,
|
|
105
|
+
`CREATE OR REPLACE FUNCTION app_rls_tenant_permission(
|
|
106
|
+
p_tenant uuid,
|
|
107
|
+
p_permission text
|
|
108
|
+
)
|
|
109
|
+
RETURNS boolean
|
|
110
|
+
LANGUAGE sql
|
|
111
|
+
STABLE
|
|
112
|
+
SECURITY DEFINER
|
|
113
|
+
${FUNCTION_SEARCH_PATH}
|
|
114
|
+
AS $fn$
|
|
115
|
+
SELECT app_rls_has_permission(
|
|
116
|
+
p_tenant,
|
|
117
|
+
p_permission,
|
|
118
|
+
'tenant',
|
|
119
|
+
p_tenant::text
|
|
120
|
+
)
|
|
121
|
+
$fn$;`,
|
|
122
|
+
`CREATE OR REPLACE FUNCTION app_rls_org_unit_permission(
|
|
123
|
+
p_tenant uuid,
|
|
124
|
+
p_org_unit uuid,
|
|
125
|
+
p_permission text
|
|
126
|
+
)
|
|
127
|
+
RETURNS boolean
|
|
128
|
+
LANGUAGE sql
|
|
129
|
+
STABLE
|
|
130
|
+
SECURITY DEFINER
|
|
131
|
+
${FUNCTION_SEARCH_PATH}
|
|
132
|
+
AS $fn$
|
|
133
|
+
SELECT app_rls_has_permission(
|
|
134
|
+
p_tenant,
|
|
135
|
+
p_permission,
|
|
136
|
+
'tenant',
|
|
137
|
+
p_tenant::text
|
|
138
|
+
)
|
|
139
|
+
OR (
|
|
140
|
+
p_org_unit IS NOT NULL
|
|
141
|
+
AND app_rls_has_permission(
|
|
142
|
+
p_tenant,
|
|
143
|
+
p_permission,
|
|
144
|
+
'org_unit',
|
|
145
|
+
p_org_unit::text
|
|
146
|
+
)
|
|
147
|
+
)
|
|
148
|
+
$fn$;`,
|
|
149
|
+
`CREATE OR REPLACE FUNCTION app_rls_is_tenant_member(p_tenant uuid)
|
|
150
|
+
RETURNS boolean
|
|
151
|
+
LANGUAGE sql
|
|
152
|
+
STABLE
|
|
153
|
+
SECURITY DEFINER
|
|
154
|
+
${FUNCTION_SEARCH_PATH}
|
|
155
|
+
AS $fn$
|
|
156
|
+
SELECT EXISTS (
|
|
157
|
+
SELECT 1
|
|
158
|
+
FROM tenant_memberships tm
|
|
159
|
+
WHERE tm.tenant_id = p_tenant
|
|
160
|
+
AND tm.status = 'active'
|
|
161
|
+
AND tm.user_id::text = app_rls_subject_id()
|
|
162
|
+
)
|
|
163
|
+
$fn$;`,
|
|
164
|
+
`CREATE OR REPLACE FUNCTION app_rls_is_org_unit_member(
|
|
165
|
+
p_tenant uuid,
|
|
166
|
+
p_org_unit uuid
|
|
167
|
+
)
|
|
168
|
+
RETURNS boolean
|
|
169
|
+
LANGUAGE sql
|
|
170
|
+
STABLE
|
|
171
|
+
SECURITY DEFINER
|
|
172
|
+
${FUNCTION_SEARCH_PATH}
|
|
173
|
+
AS $fn$
|
|
174
|
+
SELECT EXISTS (
|
|
175
|
+
SELECT 1
|
|
176
|
+
FROM org_unit_memberships m
|
|
177
|
+
WHERE m.tenant_id = p_tenant
|
|
178
|
+
AND m.org_unit_id = p_org_unit
|
|
179
|
+
AND m.status = 'active'
|
|
180
|
+
AND m.user_id::text = app_rls_subject_id()
|
|
181
|
+
)
|
|
182
|
+
$fn$;`,
|
|
183
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_read_tenant(p_tenant uuid)
|
|
184
|
+
RETURNS boolean
|
|
185
|
+
LANGUAGE sql
|
|
186
|
+
STABLE
|
|
187
|
+
SECURITY DEFINER
|
|
188
|
+
${FUNCTION_SEARCH_PATH}
|
|
189
|
+
AS $fn$
|
|
190
|
+
SELECT app_rls_tenant_permission(p_tenant, 'namespace.admin')
|
|
191
|
+
OR app_rls_tenant_permission(p_tenant, 'namespace.write')
|
|
192
|
+
OR app_rls_tenant_permission(p_tenant, 'namespace.read')
|
|
193
|
+
$fn$;`,
|
|
194
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_write_tenant(p_tenant uuid)
|
|
195
|
+
RETURNS boolean
|
|
196
|
+
LANGUAGE sql
|
|
197
|
+
STABLE
|
|
198
|
+
SECURITY DEFINER
|
|
199
|
+
${FUNCTION_SEARCH_PATH}
|
|
200
|
+
AS $fn$
|
|
201
|
+
SELECT app_rls_tenant_permission(p_tenant, 'namespace.admin')
|
|
202
|
+
OR app_rls_tenant_permission(p_tenant, 'namespace.write')
|
|
203
|
+
$fn$;`,
|
|
204
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_read_org_unit(
|
|
205
|
+
p_tenant uuid,
|
|
206
|
+
p_org_unit uuid
|
|
207
|
+
)
|
|
208
|
+
RETURNS boolean
|
|
209
|
+
LANGUAGE sql
|
|
210
|
+
STABLE
|
|
211
|
+
SECURITY DEFINER
|
|
212
|
+
${FUNCTION_SEARCH_PATH}
|
|
213
|
+
AS $fn$
|
|
214
|
+
SELECT app_rls_can_read_tenant(p_tenant)
|
|
215
|
+
OR app_rls_org_unit_permission(p_tenant, p_org_unit, 'namespace.admin')
|
|
216
|
+
OR app_rls_org_unit_permission(p_tenant, p_org_unit, 'namespace.write')
|
|
217
|
+
OR app_rls_org_unit_permission(p_tenant, p_org_unit, 'namespace.read')
|
|
218
|
+
OR app_rls_is_org_unit_member(p_tenant, p_org_unit)
|
|
219
|
+
$fn$;`,
|
|
220
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_write_org_unit(
|
|
221
|
+
p_tenant uuid,
|
|
222
|
+
p_org_unit uuid
|
|
223
|
+
)
|
|
224
|
+
RETURNS boolean
|
|
225
|
+
LANGUAGE sql
|
|
226
|
+
STABLE
|
|
227
|
+
SECURITY DEFINER
|
|
228
|
+
${FUNCTION_SEARCH_PATH}
|
|
229
|
+
AS $fn$
|
|
230
|
+
SELECT app_rls_can_write_tenant(p_tenant)
|
|
231
|
+
OR app_rls_org_unit_permission(p_tenant, p_org_unit, 'namespace.admin')
|
|
232
|
+
OR app_rls_org_unit_permission(p_tenant, p_org_unit, 'namespace.write')
|
|
233
|
+
$fn$;`,
|
|
234
|
+
`CREATE OR REPLACE FUNCTION app_rls_is_admin()
|
|
235
|
+
RETURNS boolean
|
|
236
|
+
LANGUAGE sql
|
|
237
|
+
STABLE
|
|
238
|
+
SECURITY DEFINER
|
|
239
|
+
${FUNCTION_SEARCH_PATH}
|
|
240
|
+
AS $fn$
|
|
241
|
+
SELECT EXISTS (
|
|
242
|
+
SELECT 1
|
|
243
|
+
FROM effective_permissions ep
|
|
244
|
+
WHERE ep.principal_id = app_rls_principal_id()
|
|
245
|
+
AND ep.permission_key = 'namespace.admin'
|
|
246
|
+
AND (ep.starts_at IS NULL OR ep.starts_at <= now())
|
|
247
|
+
AND (ep.expires_at IS NULL OR ep.expires_at >= now())
|
|
248
|
+
)
|
|
249
|
+
$fn$;`,
|
|
250
|
+
`CREATE OR REPLACE FUNCTION app_rls_is_tenant_admin(p_tenant uuid)
|
|
251
|
+
RETURNS boolean
|
|
252
|
+
LANGUAGE sql
|
|
253
|
+
STABLE
|
|
254
|
+
SECURITY DEFINER
|
|
255
|
+
${FUNCTION_SEARCH_PATH}
|
|
256
|
+
AS $fn$
|
|
257
|
+
SELECT app_rls_tenant_permission(p_tenant, 'namespace.admin')
|
|
258
|
+
$fn$;`,
|
|
259
|
+
`CREATE OR REPLACE FUNCTION app_rls_is_org_unit_admin(
|
|
260
|
+
p_tenant uuid,
|
|
261
|
+
p_org_unit uuid
|
|
262
|
+
)
|
|
263
|
+
RETURNS boolean
|
|
264
|
+
LANGUAGE sql
|
|
265
|
+
STABLE
|
|
266
|
+
SECURITY DEFINER
|
|
267
|
+
${FUNCTION_SEARCH_PATH}
|
|
268
|
+
AS $fn$
|
|
269
|
+
SELECT app_rls_is_tenant_admin(p_tenant)
|
|
270
|
+
OR (
|
|
271
|
+
p_org_unit IS NOT NULL
|
|
272
|
+
AND app_rls_org_unit_permission(p_tenant, p_org_unit, 'namespace.admin')
|
|
273
|
+
)
|
|
274
|
+
$fn$;`,
|
|
275
|
+
`CREATE OR REPLACE FUNCTION app_rls_is_scope_admin(
|
|
276
|
+
p_tenant uuid,
|
|
277
|
+
p_scope_kind text,
|
|
278
|
+
p_scope_id text
|
|
279
|
+
)
|
|
280
|
+
RETURNS boolean
|
|
281
|
+
LANGUAGE sql
|
|
282
|
+
STABLE
|
|
283
|
+
SECURITY DEFINER
|
|
284
|
+
${FUNCTION_SEARCH_PATH}
|
|
285
|
+
AS $fn$
|
|
286
|
+
SELECT CASE
|
|
287
|
+
WHEN p_scope_kind = 'tenant' THEN app_rls_is_tenant_admin(p_tenant)
|
|
288
|
+
WHEN p_scope_kind = 'org_unit' THEN app_rls_is_org_unit_admin(
|
|
289
|
+
p_tenant,
|
|
290
|
+
p_scope_id::uuid
|
|
291
|
+
)
|
|
292
|
+
WHEN p_scope_kind = 'resource' THEN EXISTS (
|
|
293
|
+
SELECT 1
|
|
294
|
+
FROM protected_resources r
|
|
295
|
+
WHERE r.id = p_scope_id::uuid
|
|
296
|
+
AND r.tenant_id = p_tenant
|
|
297
|
+
AND app_rls_is_org_unit_admin(p_tenant, r.org_unit_id)
|
|
298
|
+
)
|
|
299
|
+
ELSE false
|
|
300
|
+
END
|
|
301
|
+
$fn$;`,
|
|
302
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_admin_user(p_user_id uuid)
|
|
303
|
+
RETURNS boolean
|
|
304
|
+
LANGUAGE sql
|
|
305
|
+
STABLE
|
|
306
|
+
SECURITY DEFINER
|
|
307
|
+
${FUNCTION_SEARCH_PATH}
|
|
308
|
+
AS $fn$
|
|
309
|
+
SELECT EXISTS (
|
|
310
|
+
SELECT 1
|
|
311
|
+
FROM tenant_memberships tm
|
|
312
|
+
WHERE tm.user_id = p_user_id
|
|
313
|
+
AND app_rls_is_tenant_admin(tm.tenant_id)
|
|
314
|
+
)
|
|
315
|
+
$fn$;`,
|
|
316
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_read_group(
|
|
317
|
+
p_tenant uuid,
|
|
318
|
+
p_group uuid
|
|
319
|
+
)
|
|
320
|
+
RETURNS boolean
|
|
321
|
+
LANGUAGE sql
|
|
322
|
+
STABLE
|
|
323
|
+
SECURITY DEFINER
|
|
324
|
+
${FUNCTION_SEARCH_PATH}
|
|
325
|
+
AS $fn$
|
|
326
|
+
SELECT EXISTS (
|
|
327
|
+
SELECT 1
|
|
328
|
+
FROM groups g
|
|
329
|
+
WHERE g.id = p_group
|
|
330
|
+
AND g.tenant_id = p_tenant
|
|
331
|
+
AND (
|
|
332
|
+
(g.org_unit_id IS NULL AND app_rls_can_read_tenant(p_tenant))
|
|
333
|
+
OR (
|
|
334
|
+
g.org_unit_id IS NOT NULL
|
|
335
|
+
AND app_rls_can_read_org_unit(p_tenant, g.org_unit_id)
|
|
336
|
+
)
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
$fn$;`,
|
|
340
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_write_group(
|
|
341
|
+
p_tenant uuid,
|
|
342
|
+
p_group uuid
|
|
343
|
+
)
|
|
344
|
+
RETURNS boolean
|
|
345
|
+
LANGUAGE sql
|
|
346
|
+
STABLE
|
|
347
|
+
SECURITY DEFINER
|
|
348
|
+
${FUNCTION_SEARCH_PATH}
|
|
349
|
+
AS $fn$
|
|
350
|
+
SELECT EXISTS (
|
|
351
|
+
SELECT 1
|
|
352
|
+
FROM groups g
|
|
353
|
+
WHERE g.id = p_group
|
|
354
|
+
AND g.tenant_id = p_tenant
|
|
355
|
+
AND (
|
|
356
|
+
(g.org_unit_id IS NULL AND app_rls_can_write_tenant(p_tenant))
|
|
357
|
+
OR (
|
|
358
|
+
g.org_unit_id IS NOT NULL
|
|
359
|
+
AND app_rls_can_write_org_unit(p_tenant, g.org_unit_id)
|
|
360
|
+
)
|
|
361
|
+
)
|
|
362
|
+
)
|
|
363
|
+
$fn$;`,
|
|
364
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_read_resource(
|
|
365
|
+
p_tenant uuid,
|
|
366
|
+
p_resource uuid
|
|
367
|
+
)
|
|
368
|
+
RETURNS boolean
|
|
369
|
+
LANGUAGE sql
|
|
370
|
+
STABLE
|
|
371
|
+
SECURITY DEFINER
|
|
372
|
+
${FUNCTION_SEARCH_PATH}
|
|
373
|
+
AS $fn$
|
|
374
|
+
SELECT EXISTS (
|
|
375
|
+
SELECT 1
|
|
376
|
+
FROM protected_resources r
|
|
377
|
+
WHERE r.id = p_resource
|
|
378
|
+
AND r.tenant_id = p_tenant
|
|
379
|
+
AND (
|
|
380
|
+
r.owner_principal_id = app_rls_principal_id()
|
|
381
|
+
OR app_rls_is_org_unit_admin(p_tenant, r.org_unit_id)
|
|
382
|
+
OR (
|
|
383
|
+
r.visibility = 'tenant'
|
|
384
|
+
AND app_rls_can_read_tenant(p_tenant)
|
|
385
|
+
)
|
|
386
|
+
OR (
|
|
387
|
+
r.visibility IN ('org_unit', 'org_subtree')
|
|
388
|
+
AND app_rls_can_read_org_unit(p_tenant, r.org_unit_id)
|
|
389
|
+
)
|
|
390
|
+
OR EXISTS (
|
|
391
|
+
SELECT 1
|
|
392
|
+
FROM resource_grants g
|
|
393
|
+
WHERE g.resource_id = r.id
|
|
394
|
+
AND g.principal_id = app_rls_principal_id()
|
|
395
|
+
AND g.permission_key IN (
|
|
396
|
+
'resource.read',
|
|
397
|
+
'namespace.read',
|
|
398
|
+
'namespace.write',
|
|
399
|
+
'namespace.admin'
|
|
400
|
+
)
|
|
401
|
+
AND (g.starts_at IS NULL OR g.starts_at <= now())
|
|
402
|
+
AND (g.expires_at IS NULL OR g.expires_at >= now())
|
|
403
|
+
)
|
|
404
|
+
)
|
|
405
|
+
)
|
|
406
|
+
$fn$;`,
|
|
407
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_write_resource(
|
|
408
|
+
p_tenant uuid,
|
|
409
|
+
p_resource uuid
|
|
410
|
+
)
|
|
411
|
+
RETURNS boolean
|
|
412
|
+
LANGUAGE sql
|
|
413
|
+
STABLE
|
|
414
|
+
SECURITY DEFINER
|
|
415
|
+
${FUNCTION_SEARCH_PATH}
|
|
416
|
+
AS $fn$
|
|
417
|
+
SELECT EXISTS (
|
|
418
|
+
SELECT 1
|
|
419
|
+
FROM protected_resources r
|
|
420
|
+
WHERE r.id = p_resource
|
|
421
|
+
AND r.tenant_id = p_tenant
|
|
422
|
+
AND (
|
|
423
|
+
app_rls_is_org_unit_admin(p_tenant, r.org_unit_id)
|
|
424
|
+
OR app_rls_can_write_org_unit(p_tenant, r.org_unit_id)
|
|
425
|
+
)
|
|
426
|
+
)
|
|
427
|
+
$fn$;`,
|
|
428
|
+
`CREATE OR REPLACE FUNCTION app_rls_is_role_admin(p_role uuid)
|
|
429
|
+
RETURNS boolean
|
|
430
|
+
LANGUAGE sql
|
|
431
|
+
STABLE
|
|
432
|
+
SECURITY DEFINER
|
|
433
|
+
${FUNCTION_SEARCH_PATH}
|
|
434
|
+
AS $fn$
|
|
435
|
+
SELECT EXISTS (
|
|
436
|
+
SELECT 1
|
|
437
|
+
FROM roles r
|
|
438
|
+
WHERE r.id = p_role
|
|
439
|
+
AND (
|
|
440
|
+
(r.tenant_id IS NULL AND app_rls_is_admin())
|
|
441
|
+
OR (
|
|
442
|
+
r.tenant_id IS NOT NULL
|
|
443
|
+
AND app_rls_is_tenant_admin(r.tenant_id)
|
|
444
|
+
)
|
|
445
|
+
)
|
|
446
|
+
)
|
|
447
|
+
$fn$;`,
|
|
448
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_read_credential_scope(
|
|
449
|
+
p_tenant uuid,
|
|
450
|
+
p_org_unit uuid
|
|
451
|
+
)
|
|
452
|
+
RETURNS boolean
|
|
453
|
+
LANGUAGE sql
|
|
454
|
+
STABLE
|
|
455
|
+
SECURITY DEFINER
|
|
456
|
+
${FUNCTION_SEARCH_PATH}
|
|
457
|
+
AS $fn$
|
|
458
|
+
SELECT CASE
|
|
459
|
+
WHEN p_org_unit IS NULL THEN app_rls_can_read_tenant(p_tenant)
|
|
460
|
+
ELSE app_rls_can_read_org_unit(p_tenant, p_org_unit)
|
|
461
|
+
END
|
|
462
|
+
$fn$;`,
|
|
463
|
+
`CREATE OR REPLACE FUNCTION app_rls_can_write_credential_scope(
|
|
464
|
+
p_tenant uuid,
|
|
465
|
+
p_org_unit uuid
|
|
466
|
+
)
|
|
467
|
+
RETURNS boolean
|
|
468
|
+
LANGUAGE sql
|
|
469
|
+
STABLE
|
|
470
|
+
SECURITY DEFINER
|
|
471
|
+
${FUNCTION_SEARCH_PATH}
|
|
472
|
+
AS $fn$
|
|
473
|
+
SELECT CASE
|
|
474
|
+
WHEN p_org_unit IS NULL THEN app_rls_can_write_tenant(p_tenant)
|
|
475
|
+
ELSE app_rls_can_write_org_unit(p_tenant, p_org_unit)
|
|
476
|
+
END
|
|
477
|
+
$fn$;`,
|
|
478
|
+
];
|
|
479
|
+
const ADMIN = "app_rls_is_admin()";
|
|
480
|
+
const TENANT_ADMIN = "app_rls_is_tenant_admin(tenant_id)";
|
|
481
|
+
const WRITE_SCOPE = "app_rls_can_write_org_unit(tenant_id, org_unit_id)";
|
|
482
|
+
const CREDENTIAL_READ = "app_rls_can_read_credential_scope(tenant_id, org_unit_id)";
|
|
483
|
+
const CREDENTIAL_WRITE = "app_rls_can_write_credential_scope(tenant_id, org_unit_id)";
|
|
484
|
+
/**
|
|
485
|
+
* @description Canonical reader/writer/admin policy matrix.
|
|
486
|
+
* @summary Administrative tables (permissions, roles, role assignments,
|
|
487
|
+
* inheritance blocks, storage bindings) are visible only to admins. Content
|
|
488
|
+
* tables are visible to readers and writable by writers. Users always see their
|
|
489
|
+
* own identity rows and their own credentials/secrets.
|
|
490
|
+
*/
|
|
491
|
+
exports.NAMESPACE_RLS_POLICY_SETS = [
|
|
492
|
+
{
|
|
493
|
+
table: "tenants",
|
|
494
|
+
select: "app_rls_is_tenant_member(id) OR app_rls_can_read_tenant(id)",
|
|
495
|
+
insert: ADMIN,
|
|
496
|
+
update: "app_rls_is_tenant_admin(id)",
|
|
497
|
+
delete: "app_rls_is_tenant_admin(id)",
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
table: "org_units",
|
|
501
|
+
select: "app_rls_can_read_org_unit(tenant_id, id) OR (parent_id IS NOT NULL AND app_rls_can_write_org_unit(tenant_id, parent_id))",
|
|
502
|
+
insert: "app_rls_can_write_tenant(tenant_id) OR (parent_id IS NOT NULL AND app_rls_can_write_org_unit(tenant_id, parent_id))",
|
|
503
|
+
update: "app_rls_can_write_org_unit(tenant_id, id) OR (parent_id IS NOT NULL AND app_rls_can_write_org_unit(tenant_id, parent_id))",
|
|
504
|
+
delete: "app_rls_can_write_org_unit(tenant_id, id) OR (parent_id IS NOT NULL AND app_rls_can_write_org_unit(tenant_id, parent_id))",
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
table: "org_unit_closure",
|
|
508
|
+
select: "app_rls_can_read_org_unit(tenant_id, descendant_org_unit_id)",
|
|
509
|
+
insert: "app_rls_can_write_org_unit(tenant_id, descendant_org_unit_id)",
|
|
510
|
+
update: "app_rls_can_write_org_unit(tenant_id, descendant_org_unit_id)",
|
|
511
|
+
delete: "app_rls_can_write_org_unit(tenant_id, descendant_org_unit_id)",
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
table: "users",
|
|
515
|
+
select: "id::text = app_rls_subject_id() OR app_rls_can_admin_user(id)",
|
|
516
|
+
insert: ADMIN,
|
|
517
|
+
update: "id::text = app_rls_subject_id() OR app_rls_can_admin_user(id)",
|
|
518
|
+
delete: "app_rls_can_admin_user(id)",
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
table: "groups",
|
|
522
|
+
select: "app_rls_can_read_group(tenant_id, id)",
|
|
523
|
+
insert: "app_rls_can_write_tenant(tenant_id) OR (org_unit_id IS NOT NULL AND app_rls_can_write_org_unit(tenant_id, org_unit_id))",
|
|
524
|
+
update: "app_rls_can_write_group(tenant_id, id)",
|
|
525
|
+
delete: "app_rls_can_write_group(tenant_id, id)",
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
table: "principals",
|
|
529
|
+
select: "id = app_rls_principal_id() OR (kind = 'user' AND subject_id = app_rls_subject_id()) OR app_rls_is_tenant_admin(tenant_id)",
|
|
530
|
+
insert: TENANT_ADMIN,
|
|
531
|
+
update: TENANT_ADMIN,
|
|
532
|
+
delete: TENANT_ADMIN,
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
table: "tenant_memberships",
|
|
536
|
+
select: "user_id::text = app_rls_subject_id() OR app_rls_can_read_tenant(tenant_id)",
|
|
537
|
+
insert: TENANT_ADMIN,
|
|
538
|
+
update: TENANT_ADMIN,
|
|
539
|
+
delete: TENANT_ADMIN,
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
table: "org_unit_memberships",
|
|
543
|
+
select: "user_id::text = app_rls_subject_id() OR app_rls_org_unit_permission(tenant_id, org_unit_id, 'namespace.admin') OR app_rls_org_unit_permission(tenant_id, org_unit_id, 'namespace.write') OR app_rls_org_unit_permission(tenant_id, org_unit_id, 'namespace.read')",
|
|
544
|
+
insert: WRITE_SCOPE,
|
|
545
|
+
update: WRITE_SCOPE,
|
|
546
|
+
delete: WRITE_SCOPE,
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
table: "group_memberships",
|
|
550
|
+
select: "app_rls_can_read_group(tenant_id, group_id)",
|
|
551
|
+
insert: "app_rls_can_write_group(tenant_id, group_id)",
|
|
552
|
+
update: "app_rls_can_write_group(tenant_id, group_id)",
|
|
553
|
+
delete: "app_rls_can_write_group(tenant_id, group_id)",
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
table: "permissions",
|
|
557
|
+
select: ADMIN,
|
|
558
|
+
insert: ADMIN,
|
|
559
|
+
update: ADMIN,
|
|
560
|
+
delete: ADMIN,
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
table: "roles",
|
|
564
|
+
select: "(tenant_id IS NOT NULL AND app_rls_is_tenant_admin(tenant_id)) OR (tenant_id IS NULL AND app_rls_is_admin())",
|
|
565
|
+
insert: "(tenant_id IS NOT NULL AND app_rls_is_tenant_admin(tenant_id)) OR (tenant_id IS NULL AND app_rls_is_admin())",
|
|
566
|
+
update: "(tenant_id IS NOT NULL AND app_rls_is_tenant_admin(tenant_id)) OR (tenant_id IS NULL AND app_rls_is_admin())",
|
|
567
|
+
delete: "(tenant_id IS NOT NULL AND app_rls_is_tenant_admin(tenant_id)) OR (tenant_id IS NULL AND app_rls_is_admin())",
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
table: "role_permissions",
|
|
571
|
+
select: "app_rls_is_role_admin(role_id)",
|
|
572
|
+
insert: "app_rls_is_role_admin(role_id)",
|
|
573
|
+
update: "app_rls_is_role_admin(role_id)",
|
|
574
|
+
delete: "app_rls_is_role_admin(role_id)",
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
table: "role_assignments",
|
|
578
|
+
select: "app_rls_is_scope_admin(tenant_id, scope_kind, scope_id)",
|
|
579
|
+
insert: "app_rls_is_scope_admin(tenant_id, scope_kind, scope_id)",
|
|
580
|
+
update: "app_rls_is_scope_admin(tenant_id, scope_kind, scope_id)",
|
|
581
|
+
delete: "app_rls_is_scope_admin(tenant_id, scope_kind, scope_id)",
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
table: "inheritance_blocks",
|
|
585
|
+
select: "app_rls_is_org_unit_admin(tenant_id, org_unit_id)",
|
|
586
|
+
insert: "app_rls_is_org_unit_admin(tenant_id, org_unit_id)",
|
|
587
|
+
update: "app_rls_is_org_unit_admin(tenant_id, org_unit_id)",
|
|
588
|
+
delete: "app_rls_is_org_unit_admin(tenant_id, org_unit_id)",
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
table: "protected_resources",
|
|
592
|
+
select: "app_rls_can_read_resource(tenant_id, id)",
|
|
593
|
+
insert: "app_rls_can_write_tenant(tenant_id) OR (org_unit_id IS NOT NULL AND app_rls_can_write_org_unit(tenant_id, org_unit_id))",
|
|
594
|
+
update: "app_rls_can_write_resource(tenant_id, id)",
|
|
595
|
+
delete: "app_rls_can_write_resource(tenant_id, id)",
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
table: "resource_grants",
|
|
599
|
+
select: "principal_id = app_rls_principal_id() OR app_rls_can_read_resource(tenant_id, resource_id)",
|
|
600
|
+
insert: "app_rls_can_write_resource(tenant_id, resource_id)",
|
|
601
|
+
update: "app_rls_can_write_resource(tenant_id, resource_id)",
|
|
602
|
+
delete: "app_rls_can_write_resource(tenant_id, resource_id)",
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
table: "effective_permissions",
|
|
606
|
+
select: "principal_id = app_rls_principal_id() OR app_rls_is_scope_admin(tenant_id, scope_kind, scope_id)",
|
|
607
|
+
insert: "app_rls_is_scope_admin(tenant_id, scope_kind, scope_id)",
|
|
608
|
+
update: "app_rls_is_scope_admin(tenant_id, scope_kind, scope_id)",
|
|
609
|
+
delete: "app_rls_is_scope_admin(tenant_id, scope_kind, scope_id)",
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
table: "storage_bindings",
|
|
613
|
+
select: TENANT_ADMIN,
|
|
614
|
+
insert: TENANT_ADMIN,
|
|
615
|
+
update: TENANT_ADMIN,
|
|
616
|
+
delete: TENANT_ADMIN,
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
table: "tenant_profiles",
|
|
620
|
+
select: "app_rls_is_tenant_member(tenant_id) OR app_rls_can_read_tenant(tenant_id)",
|
|
621
|
+
insert: TENANT_ADMIN,
|
|
622
|
+
update: TENANT_ADMIN,
|
|
623
|
+
delete: TENANT_ADMIN,
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
table: "org_unit_profiles",
|
|
627
|
+
select: "app_rls_can_read_org_unit(app_rls_org_unit_tenant(org_unit_id), org_unit_id)",
|
|
628
|
+
insert: "app_rls_can_write_org_unit(app_rls_org_unit_tenant(org_unit_id), org_unit_id)",
|
|
629
|
+
update: "app_rls_can_write_org_unit(app_rls_org_unit_tenant(org_unit_id), org_unit_id)",
|
|
630
|
+
delete: "app_rls_can_write_org_unit(app_rls_org_unit_tenant(org_unit_id), org_unit_id)",
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
table: "credentials",
|
|
634
|
+
select: "owner_principal_id = app_rls_principal_id() OR " + CREDENTIAL_READ,
|
|
635
|
+
insert: CREDENTIAL_WRITE,
|
|
636
|
+
update: CREDENTIAL_WRITE,
|
|
637
|
+
delete: CREDENTIAL_WRITE,
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
table: "secrets",
|
|
641
|
+
select: "owner_principal_id = app_rls_principal_id() OR " +
|
|
642
|
+
CREDENTIAL_READ +
|
|
643
|
+
" OR (tenant_id IS NULL AND app_rls_is_admin())",
|
|
644
|
+
insert: CREDENTIAL_WRITE + " OR (tenant_id IS NULL AND app_rls_is_admin())",
|
|
645
|
+
update: CREDENTIAL_WRITE + " OR (tenant_id IS NULL AND app_rls_is_admin())",
|
|
646
|
+
delete: CREDENTIAL_WRITE + " OR (tenant_id IS NULL AND app_rls_is_admin())",
|
|
647
|
+
},
|
|
648
|
+
];
|
|
649
|
+
/**
|
|
650
|
+
* @description Generates enable/force and policy DDL for a policy set.
|
|
651
|
+
* @summary `DROP POLICY IF EXISTS` makes the output safe to replay on every
|
|
652
|
+
* deployment. Missing command expressions leave that command denied.
|
|
653
|
+
*/
|
|
654
|
+
function rlsPolicyStatements(policySets = exports.NAMESPACE_RLS_POLICY_SETS) {
|
|
655
|
+
const statements = [];
|
|
656
|
+
for (const set of policySets) {
|
|
657
|
+
if (set.enable !== false) {
|
|
658
|
+
statements.push(`ALTER TABLE ${set.table} ENABLE ROW LEVEL SECURITY;`, `ALTER TABLE ${set.table} FORCE ROW LEVEL SECURITY;`);
|
|
659
|
+
}
|
|
660
|
+
const prefix = set.table.replace(/[^A-Za-z0-9_]/g, "_");
|
|
661
|
+
const commands = [
|
|
662
|
+
[
|
|
663
|
+
"select",
|
|
664
|
+
set.select,
|
|
665
|
+
(name, expression) => `CREATE POLICY ${name} ON ${set.table} FOR SELECT USING (${expression});`,
|
|
666
|
+
],
|
|
667
|
+
[
|
|
668
|
+
"insert",
|
|
669
|
+
set.insert,
|
|
670
|
+
(name, expression) => `CREATE POLICY ${name} ON ${set.table} FOR INSERT WITH CHECK (${expression});`,
|
|
671
|
+
],
|
|
672
|
+
[
|
|
673
|
+
"update",
|
|
674
|
+
set.update,
|
|
675
|
+
(name, expression) => `CREATE POLICY ${name} ON ${set.table} FOR UPDATE USING (${expression}) WITH CHECK (${expression});`,
|
|
676
|
+
],
|
|
677
|
+
[
|
|
678
|
+
"delete",
|
|
679
|
+
set.delete,
|
|
680
|
+
(name, expression) => `CREATE POLICY ${name} ON ${set.table} FOR DELETE USING (${expression});`,
|
|
681
|
+
],
|
|
682
|
+
];
|
|
683
|
+
for (const [command, expression, render] of commands) {
|
|
684
|
+
if (!expression)
|
|
685
|
+
continue;
|
|
686
|
+
const name = `${prefix}_${command}_policy`;
|
|
687
|
+
statements.push(`DROP POLICY IF EXISTS ${name} ON ${set.table};`, render(name, expression));
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return statements;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* @description Full namespace RLS bootstrap statement list.
|
|
694
|
+
* @summary Helper functions followed by enable/force and policy DDL for every
|
|
695
|
+
* table in {@link RLS_PROTECTED_TABLES}. Apply after the namespace schema
|
|
696
|
+
* exists and before request-scoped traffic reaches the database.
|
|
697
|
+
*/
|
|
698
|
+
function rlsBootstrapStatements() {
|
|
699
|
+
return [...exports.RLS_FUNCTION_STATEMENTS, ...rlsPolicyStatements()];
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* @description Tables targeted by the bundled namespace template.
|
|
703
|
+
*/
|
|
704
|
+
function rlsPolicyTables(policySets = exports.NAMESPACE_RLS_POLICY_SETS) {
|
|
705
|
+
return policySets.map((set) => set.table);
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* @description Asserts that the bundled policy template covers every protected
|
|
709
|
+
* table. Exposed for deployment checks and unit tests.
|
|
710
|
+
*/
|
|
711
|
+
function assertRlsTableCoverage(policySets = exports.NAMESPACE_RLS_POLICY_SETS) {
|
|
712
|
+
const covered = new Set(rlsPolicyTables(policySets));
|
|
713
|
+
const missing = rls_constants_js_1.RLS_PROTECTED_TABLES.filter((table) => !covered.has(table));
|
|
714
|
+
if (missing.length) {
|
|
715
|
+
throw new db_decorators_1.InternalError(`RLS template is missing tables: ${missing.join(", ")}`);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
//# sourceMappingURL=rls.template.js.map
|
|
719
|
+
//# sourceMappingURL=rls.template.cjs.map
|