diff --git a/apis/workflows/v1/automation.proto b/apis/workflows/v1/automation.proto index ef7c871..a1b7041 100644 --- a/apis/workflows/v1/automation.proto +++ b/apis/workflows/v1/automation.proto @@ -58,7 +58,7 @@ message StorageEventTrigger { tilebox.v1.ID id = 1; // The storage location to watch for events StorageLocation storage_location = 2; - // A glob pattern to match objects/files in the storage location + // Glob pattern matched against object keys relative to the storage location's root_prefix. string glob_pattern = 3 [(buf.validate.field).string.min_len = 1]; } diff --git a/apis/workflows/v1/resource.proto b/apis/workflows/v1/resource.proto index 48d40eb..0e9042f 100644 --- a/apis/workflows/v1/resource.proto +++ b/apis/workflows/v1/resource.proto @@ -41,17 +41,11 @@ message EnvironmentVariable { ClusterScope scope = 4; // Get/List return the full value for non-secrets and explicit reveals. Create/Update omit it. // A missing value is hidden. Never log values, even non-secrets. - string value = 5 [ - features.field_presence = EXPLICIT, - debug_redact = true - ]; + string value = 5 [features.field_presence = EXPLICIT]; // Get/List return this preview only for hidden secrets. // For display only. Never log the preview or pass it to a runner. // Non-secrets, reveals, and Create/Update responses omit it. - string secret_preview = 6 [ - features.field_presence = EXPLICIT, - debug_redact = true - ]; + string secret_preview = 6 [features.field_presence = EXPLICIT]; // A description visible to anyone who can read this entry. Do not put credentials here. string description = 7; } @@ -61,7 +55,7 @@ message RunnerEnvironmentVariable { tilebox.v1.ID id = 1; string name = 2; // The full value, including secrets. Never masked or empty. Never log it. - string value = 3 [debug_redact = true]; + string value = 3; bool is_secret = 4; } @@ -73,7 +67,6 @@ message CreateEnvironmentVariableRequest { string name = 1 [(buf.validate.field).string.pattern = "^[A-Z_][A-Z0-9_]*$"]; // Must be nonempty. Stored as supplied, without interpolation. Never log it. string value = 2 [ - debug_redact = true, (buf.validate.field).string.min_len = 1, (buf.validate.field).string.not_contains = "\x00" ]; @@ -140,7 +133,6 @@ message UpdateEnvironmentVariableRequest { // Omit to keep the value. A supplied value must be nonempty. Never log it. string value = 3 [ features.field_presence = EXPLICIT, - debug_redact = true, (buf.validate.field).string.min_len = 1, (buf.validate.field).string.not_contains = "\x00" ]; diff --git a/apis/workflows/v1/storage_access.proto b/apis/workflows/v1/storage_access.proto new file mode 100644 index 0000000..a68a2b2 --- /dev/null +++ b/apis/workflows/v1/storage_access.proto @@ -0,0 +1,265 @@ +// Bucket access configuration and client credentials. + +edition = "2023"; + +package workflows.v1; + +import "buf/validate/validate.proto"; +import "google/api/field_behavior.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "tilebox/v1/id.proto"; + +option features.field_presence = IMPLICIT; + +// StorageAccessPermission selects the operations requested for a session. +enum StorageAccessPermission { + STORAGE_ACCESS_PERMISSION_UNSPECIFIED = 0; + // Read objects and list keys. + STORAGE_ACCESS_PERMISSION_READ = 1; + // Also write, delete, and manage multipart uploads. + STORAGE_ACCESS_PERMISSION_READ_WRITE = 2; +} + +// AWSRoleStorageAccess configures AWS role assumption. +message AWSRoleStorageAccess { + string role_arn = 1 [(buf.validate.field).string = { + max_bytes: 2048 + pattern: "^arn:aws[a-z-]*:iam::[0-9]{12}:role/.+$" + }]; + // Grant this Tilebox principal permission to assume the role. + string principal_arn = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Tilebox generates this value for the role's trust policy and preserves it on updates. + string external_id = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Allow delegated sessions to write, delete, and manage multipart uploads. Defaults to read-only. + bool allow_write = 4; +} + +// GCSImpersonationStorageAccess configures service-account impersonation. +message GCSImpersonationStorageAccess { + string service_account_email = 1 [(buf.validate.field).string = { + email: true + max_bytes: 320 + suffix: ".iam.gserviceaccount.com" + }]; + // Grant this organization's Tilebox identity permission to impersonate the service account. + string delegator_service_account_email = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Allow delegated sessions to write and delete objects. Defaults to read-only. + bool allow_write = 3; +} + +// AzureDelegationStorageAccess configures user-delegation SAS access. +message AzureDelegationStorageAccess { + // Must be linked to the caller's Tilebox organization. + string tenant_id = 1 [(buf.validate.field).string.uuid = true]; + // Grant this Tilebox application access to the storage account and container. + string application_client_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Allow delegated sessions to write and delete blobs. Defaults to read-only. + bool allow_write = 3; +} + +// AccessKeyCredentials contains an access key ID and secret for S3-compatible authentication. +// Both fields are required when configuring access; omitted fields preserve saved values on updates to the same method. +message AccessKeyCredentials { + string access_key_id = 1 [ + features.field_presence = EXPLICIT, + (google.api.field_behavior) = INPUT_ONLY, + (buf.validate.field).string.min_bytes = 1 + ]; + string secret_access_key = 2 [ + features.field_presence = EXPLICIT, + (google.api.field_behavior) = INPUT_ONLY, + (buf.validate.field).string.min_bytes = 1 + ]; +} + +// StaticS3CredentialsAccess configures access with a saved S3 key pair. +message StaticS3CredentialsAccess { + // Required when configuring this method. Updates replace supplied key fields. Location responses omit credentials. + AccessKeyCredentials credentials = 1 [(google.api.field_behavior) = INPUT_ONLY]; +} + +// R2DelegationStorageAccess uses saved parent keys to issue temporary R2 credentials. +message R2DelegationStorageAccess { + // Required when configuring this method. Updates replace supplied key fields. Parent keys stay on the backend. + AccessKeyCredentials credentials = 1 [(google.api.field_behavior) = INPUT_ONLY]; + // Allow delegated sessions to write, delete, and manage multipart uploads. Defaults to read-only. + bool allow_write = 2; +} + +// PublicHTTPStorageAccess configures unsigned reads through a public bucket endpoint. +message PublicHTTPStorageAccess { + // HTTPS bucket-root origin. Supports range reads but no listing. + string public_endpoint = 1 [(buf.validate.field).string = { + uri: true + max_bytes: 2048 + pattern: "^https://[^/?#@]+/?$" + }]; +} + +// AWSS3StorageAccess configures access to an AWS bucket. +message AWSS3StorageAccess { + option (buf.validate.message).oneof = { + fields: [ + "anonymous", + "client_managed", + "aws_role", + "static_s3" + ] + required: true + }; + + // Public, unsigned reads. + google.protobuf.Empty anonymous = 1; + // The client supplies its own credentials. + google.protobuf.Empty client_managed = 2; + AWSRoleStorageAccess aws_role = 3; + StaticS3CredentialsAccess static_s3 = 4; +} + +// GCSStorageAccess configures native GCS access or S3 interoperability through HMAC keys. +message GCSStorageAccess { + option (buf.validate.message).oneof = { + fields: [ + "anonymous", + "client_managed", + "gcs_impersonation", + "static_s3" + ] + required: true + }; + + google.protobuf.Empty anonymous = 1; + google.protobuf.Empty client_managed = 2; + GCSImpersonationStorageAccess gcs_impersonation = 3; + StaticS3CredentialsAccess static_s3 = 4; +} + +// AzureBlobStorageAccess configures access to an Azure container. +message AzureBlobStorageAccess { + option (buf.validate.message).oneof = { + fields: [ + "anonymous", + "client_managed", + "azure_delegation" + ] + required: true + }; + + google.protobuf.Empty anonymous = 1; + google.protobuf.Empty client_managed = 2; + AzureDelegationStorageAccess azure_delegation = 3; +} + +// R2StorageAccess configures access to a Cloudflare R2 bucket. +message R2StorageAccess { + option (buf.validate.message).oneof = { + fields: [ + "anonymous", + "client_managed", + "r2_delegation", + "static_s3" + ] + required: true + }; + + PublicHTTPStorageAccess anonymous = 1; + google.protobuf.Empty client_managed = 2; + R2DelegationStorageAccess r2_delegation = 3; + StaticS3CredentialsAccess static_s3 = 4; +} + +// S3CompatibleStorageAccess configures access to Tigris or another S3-compatible provider. +message S3CompatibleStorageAccess { + option (buf.validate.message).oneof = { + fields: [ + "anonymous", + "client_managed", + "static_s3" + ] + required: true + }; + + google.protobuf.Empty anonymous = 1; + google.protobuf.Empty client_managed = 2; + StaticS3CredentialsAccess static_s3 = 3; +} + +// StorageS3Connection contains client settings and static or temporary credentials for any S3-compatible provider. +message StorageS3Connection { + string endpoint = 1; + string bucket = 2; + string region = 3; + bool force_path_style = 4; + string access_key_id = 5; + string secret_access_key = 6; + // Present for temporary credentials. + string session_token = 7; +} + +// StorageGCSConnection contains native GCS client settings and credentials. +message StorageGCSConnection { + string bucket = 1; + string bearer_token = 2; +} + +// StorageAzureConnection contains Azure Blob client settings and credentials. +message StorageAzureConnection { + string endpoint = 1; + string account = 2; + string container = 3; + // SAS query string without a leading '?'. + string sas_token = 4; +} + +// CreateStorageAccessSessionRequest fetches or renews credentials for a location. +message CreateStorageAccessSessionRequest { + tilebox.v1.ID storage_location_id = 1 [(buf.validate.field).required = true]; + // Delegated READ_WRITE requires allow_write. READ always issues read-only delegated credentials. + // Static credentials retain their cloud permissions, regardless of the requested access. + StorageAccessPermission access = 2 [(buf.validate.field).enum = { + defined_only: true + not_in: [0] + }]; +} + +// StorageAccessSession contains connection settings and Tilebox-supplied credentials for a native storage client. +// Keep credentials out of logs and persistent storage. +message StorageAccessSession { + option (buf.validate.message).oneof = { + fields: [ + "s3", + "gcs", + "azure" + ] + required: true + }; + + // Client paths are relative to this root. Reopen the store if the root or target changes on renewal. + string root_prefix = 1; + // Provider expiration for delegated credentials. Call CreateStorageAccessSession again to renew. + // Absent for static credentials; reopen the store to pick up a rotated key. + google.protobuf.Timestamp expires_at = 2; + StorageS3Connection s3 = 3; + StorageGCSConnection gcs = 4; + StorageAzureConnection azure = 5; +} + +// TestStorageAccessRequest tests a scoped listing, or a small range read when object_key is supplied. +message TestStorageAccessRequest { + tilebox.v1.ID storage_location_id = 1 [(buf.validate.field).required = true]; + // Existing object relative to root_prefix. Required for public HTTP endpoints without listing. + string object_key = 2 [ + features.field_presence = EXPLICIT, + (buf.validate.field).string = { + min_bytes: 1 + max_bytes: 4096 + not_contains: "\x00" + }, + (buf.validate.field).cel = { + id: "storage_access_test.object_key" + message: "Use a relative object key without empty, '.' or '..' components." + expression: "this.split('/').all(p, p != '' && p != '.' && p != '..')" + } + ]; +} diff --git a/apis/workflows/v1/storage_location.proto b/apis/workflows/v1/storage_location.proto index 18c562b..9c43ced 100644 --- a/apis/workflows/v1/storage_location.proto +++ b/apis/workflows/v1/storage_location.proto @@ -1,4 +1,4 @@ -// The external API for managing storage locations and object notifications. +// The external API for managing storage locations, object access, and notifications. edition = "2023"; @@ -10,6 +10,7 @@ import "google/protobuf/empty.proto"; import "google/protobuf/timestamp.proto"; import "tilebox/v1/id.proto"; import "tilebox/v1/query.proto"; +import "workflows/v1/storage_access.proto"; option features.field_presence = IMPLICIT; @@ -24,9 +25,15 @@ enum StorageType { STORAGE_TYPE_LOCAL = 3; // Azure Blob Storage container STORAGE_TYPE_AZURE_BLOB = 4; + // Cloudflare R2 bucket + STORAGE_TYPE_CLOUDFLARE_R2 = 5; + // Tigris bucket + STORAGE_TYPE_TIGRIS = 6; + // Bucket served by another S3-compatible provider + STORAGE_TYPE_S3_COMPATIBLE = 7; } -// StorageLocation identifies a bucket, container, or local directory whose objects can trigger automations. +// StorageLocation identifies a bucket, container, or local directory. message StorageLocation { // Unique identifier of the storage location. tilebox.v1.ID id = 1; @@ -36,25 +43,32 @@ message StorageLocation { StorageType type = 3 [deprecated = true]; // Display name of the storage location. string name = 4 [(buf.validate.field).string.max_bytes = 1024]; - // Immutable provider coordinates of the storage location. + // Provider coordinates and optional object access. Responses omit stored credentials. StorageLocationReference reference = 5; } // StorageLocationReference identifies an existing storage resource. Set the field corresponding to type. +// Coordinates and root_prefix are fixed after creation. A supplied reference replaces the complete access configuration. +// Omitted credential fields keep saved values only when the authentication method is unchanged. +// Creating or switching to a credential-backed method requires a complete pair. Location responses omit credentials. +// Absent access disables Tilebox object access; anonymous and client-managed access must be selected explicitly. message StorageLocationReference { option (buf.validate.message).oneof = { fields: [ "aws_s3_bucket", "gcs_bucket", "azure_blob", - "local" + "local", + "s3_compatible_bucket", + "r2_bucket", + "tigris_bucket" ] required: true }; option (buf.validate.message).cel = { id: "storage_location_reference.type" message: "The storage type must match the provider reference." - expression: "(this.type == 1 && has(this.gcs_bucket)) || (this.type == 2 && has(this.aws_s3_bucket)) || (this.type == 3 && has(this.local)) || (this.type == 4 && has(this.azure_blob))" + expression: "(this.type == 1 && has(this.gcs_bucket)) || (this.type == 2 && has(this.aws_s3_bucket)) || (this.type == 3 && has(this.local)) || (this.type == 4 && has(this.azure_blob)) || (this.type == 5 && has(this.r2_bucket)) || (this.type == 6 && has(this.tigris_bucket)) || (this.type == 7 && has(this.s3_compatible_bucket))" }; AWSS3BucketReference aws_s3_bucket = 1; @@ -65,6 +79,82 @@ message StorageLocationReference { defined_only: true not_in: [0] }]; + S3CompatibleBucketReference s3_compatible_bucket = 6; + R2BucketReference r2_bucket = 7; + TigrisBucketReference tigris_bucket = 8; + // Empty for the resource root; otherwise a relative directory prefix ending in '/'. + // Scopes client paths and subscriptions. Ignore notifications outside this prefix and strip it before matching globs. + // Delegated credentials enforce the prefix; static and client-managed credentials retain their cloud scope. + string root_prefix = 9 [ + (buf.validate.field).string.max_bytes = 1024, + (buf.validate.field).string.not_contains = "\x00", + (buf.validate.field).cel = { + id: "storage_location_reference.root_prefix" + message: "Use an empty root or a relative directory prefix ending in '/' without empty, '.' or '..' components." + expression: "this == '' || (this.endsWith('/') && !this.startsWith('/') && !this.contains('//') && this.split('/').all(p, p != '.' && p != '..'))" + } + ]; +} + +// S3CompatibleBucketReference identifies a bucket at an S3 endpoint. +message S3CompatibleBucketReference { + string bucket = 1 [(buf.validate.field).string = { + min_bytes: 1 + max_bytes: 255 + }]; + // HTTP or HTTPS origin without credentials, path, query, or fragment. + string endpoint = 2 [(buf.validate.field).string = { + uri: true + max_bytes: 2048 + pattern: "^https?://[^/?#@]+/?$" + }]; + // Region used for SigV4 signing, independent of the endpoint hostname. Empty or omitted defaults to "auto". + string region = 3 [(buf.validate.field).string.max_bytes = 128]; + bool force_path_style = 4; + // Public bucket-root origin for anonymous HTTP reads. + string public_endpoint = 5 [ + features.field_presence = EXPLICIT, + (buf.validate.field).string = { + uri: true + max_bytes: 2048 + pattern: "^https?://[^/?#@]+/?$" + } + ]; + S3CompatibleStorageAccess access = 6; +} + +// R2BucketReference identifies a Cloudflare R2 bucket. +message R2BucketReference { + option (buf.validate.message).cel = { + id: "r2_bucket_reference.endpoint" + message: "An S3 endpoint is required for delegated, static, or client-managed access." + expression: "!has(this.access) || has(this.access.anonymous) || this.endpoint != ''" + }; + + string bucket = 1 [(buf.validate.field).string = { + min_bytes: 1 + max_bytes: 63 + }]; + // Account's R2 S3 endpoint, including its jurisdiction when applicable. Required for S3 access. + // Signing region is auto. + string endpoint = 2 [ + (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + (buf.validate.field).string = { + uri: true + max_bytes: 2048 + pattern: "^https://[^/?#@]+/?$" + } + ]; + R2StorageAccess access = 3; +} + +// TigrisBucketReference identifies a Tigris bucket using its standard S3 endpoint. +message TigrisBucketReference { + string bucket = 1 [(buf.validate.field).string = { + min_bytes: 1 + max_bytes: 63 + }]; + S3CompatibleStorageAccess access = 2; } // AWSS3BucketReference identifies an Amazon Web Services S3 bucket and its region. @@ -77,6 +167,7 @@ message AWSS3BucketReference { min_bytes: 1 max_bytes: 128 }]; + AWSS3StorageAccess access = 3; } // GCSBucketReference identifies a Google Cloud Storage bucket and its project. @@ -92,6 +183,7 @@ message GCSBucketReference { }]; // Optional bucket location, such as europe-west2, EUR4, or EU. May be a region, dual-region, or multi-region. string location = 3 [(buf.validate.field).string.max_bytes = 128]; + GCSStorageAccess access = 4; } // AzureBlobReference identifies a container in an Azure storage account. @@ -107,6 +199,7 @@ message AzureBlobReference { }]; // Optional primary region of the storage account, such as westeurope. Containers use their account's region. string region = 3 [(buf.validate.field).string.max_bytes = 128]; + AzureBlobStorageAccess access = 4; } // LocalReference identifies a local directory monitored by the Tilebox CLI. @@ -129,7 +222,8 @@ message TriggeredJobs { repeated TriggeredJob triggered_jobs = 1; } -// CreateStorageLocationRequest registers an existing bucket, container, or directory as a storage location. +// CreateStorageLocationRequest registers an existing bucket, container, or directory. +// Omit the provider's access field for notification-only use. Cloud permissions can be configured after creation. message CreateStorageLocationRequest { string name = 1 [(buf.validate.field).string = { min_bytes: 1 @@ -138,13 +232,26 @@ message CreateStorageLocationRequest { StorageLocationReference reference = 2 [(buf.validate.field).required = true]; } -// UpdateStorageLocationRequest changes the display name of a storage location. +// UpdateStorageLocationRequest changes supplied fields and leaves the rest unchanged. message UpdateStorageLocationRequest { + option (buf.validate.message).cel = { + id: "update_storage_location.fields" + message: "At least one update field is required." + expression: "has(this.name) || has(this.reference)" + }; + tilebox.v1.ID storage_location_id = 1 [(buf.validate.field).required = true]; - string name = 2 [(buf.validate.field).string = { - min_bytes: 1 - max_bytes: 1024 - }]; + string name = 2 [ + features.field_presence = EXPLICIT, + (buf.validate.field).string = { + min_bytes: 1 + max_bytes: 1024 + } + ]; + // Omit to keep the reference. Supply a complete reference with unchanged coordinates and root_prefix to replace access. + // Credential fields are patched within the same access method: supplied values replace saved values; omitted fields keep them. + // Omitting access within a supplied reference removes access and saved credentials; issued keys may remain valid. + StorageLocationReference reference = 3; } // StorageSubscriptionType identifies the notification delivery provider. @@ -298,7 +405,7 @@ message StorageSubscriptions { message StorageSubscriptionEvent { // Unique identifier of the received event. tilebox.v1.ID id = 1; - // Object key within the bucket or container, or path relative to the local directory root. + // Object key relative to the location's root_prefix, or to the local directory root when no prefix is set. string object_key = 2 [(buf.validate.field).string = { min_bytes: 1 max_bytes: 4096 @@ -331,7 +438,7 @@ message StorageSubscriptionEvents { tilebox.v1.Pagination next_page = 2 [features.field_presence = EXPLICIT]; } -// StorageLocations contains storage locations available for automation triggers. +// StorageLocations contains locations available to the caller. message StorageLocations { repeated StorageLocation locations = 1; } @@ -348,23 +455,31 @@ message TriggeredStorageEvent { tilebox.v1.ID storage_location_id = 1; // The type of the storage event, e.g. created StorageEventType type = 2; - // The object key/path that triggered the task, not the storage location's provider coordinates. + // Object key relative to the location root, with root_prefix removed. string location = 3; } -// StorageLocationService manages storage locations, notification subscriptions, and received events. +// StorageLocationService manages storage locations, object access, and notifications. service StorageLocationService { - // ListStorageLocations lists storage locations available for automation triggers. + // ListStorageLocations lists locations available to the caller. rpc ListStorageLocations(google.protobuf.Empty) returns (StorageLocations); // GetStorageLocation gets a storage location by its ID. rpc GetStorageLocation(tilebox.v1.ID) returns (StorageLocation); - // CreateStorageLocation registers an existing bucket, container, or directory for automation triggers. + // CreateStorageLocation registers an existing resource with optional object access. rpc CreateStorageLocation(CreateStorageLocationRequest) returns (StorageLocation); - // UpdateStorageLocation changes the display name of a storage location. + // UpdateStorageLocation changes the name or access settings. Subscriptions are unchanged. rpc UpdateStorageLocation(UpdateStorageLocationRequest) returns (StorageLocation); // DeleteStorageLocation removes the location and its subscriptions from Tilebox without deleting cloud resources. rpc DeleteStorageLocation(tilebox.v1.ID) returns (google.protobuf.Empty); + // TestStorageAccess checks listing or reading without writing objects. Requires management permission. + // Failures use RPC errors. Client-managed access cannot be tested by Tilebox. + rpc TestStorageAccess(TestStorageAccessRequest) returns (google.protobuf.Empty); + // CreateStorageAccessSession checks data-access permission and returns static or delegated credentials. + // Returns FAILED_PRECONDITION for absent, anonymous, or client-managed access; configure those clients from the location. + // Call again to renew. Responses use Cache-Control: no-store; errors omit provider secrets. + rpc CreateStorageAccessSession(CreateStorageAccessSessionRequest) returns (StorageAccessSession); + // CreateStorageSubscription registers notification delivery and returns the provider setup values. rpc CreateStorageSubscription(CreateStorageSubscriptionRequest) returns (StorageSubscription); // ListStorageSubscriptions lists notification subscriptions for a storage location. diff --git a/apis/workflows/v1/workflows.proto b/apis/workflows/v1/workflows.proto index 4e2fdba..972320e 100644 --- a/apis/workflows/v1/workflows.proto +++ b/apis/workflows/v1/workflows.proto @@ -72,7 +72,7 @@ message GetClusterRunnerEnvironmentResponse { Cluster cluster = 1; // One entry per name, including full secret values. Cluster-specific values win over all-clusters values. // Values are literal strings, without interpolation. Replace the previous environment, even when this list is empty. - repeated RunnerEnvironmentVariable environment_variables = 2 [debug_redact = true]; + repeated RunnerEnvironmentVariable environment_variables = 2; } // UpdateClusterRequest updates an existing cluster, by updating all fields that are set to their new values.