Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/Apis/CredentialsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ All URIs are relative to *http://localhost:8080/api/2.1/unity-catalog*

Create a credential

Creates a new credential. The type of credential to be created is determined by the **purpose** field. Set exactly one of `aws_iam_role` and `s3_compatible`; otherwise the request fails with `INVALID_ARGUMENT`. EXPERIMENTAL: `s3_compatible` is available only when the server property `server.s3-compatible-storage.enabled` is `true`. Otherwise a create or update request that sets `s3_compatible`, and vending for a path under one, fail with `INVALID_ARGUMENT`; other updates, reads, lists and deletes of existing ones still work. An `s3_compatible` credential holds an access key pair of S3-compatible storage and the storage's S3 endpoint. `s3_endpoint` and `assume_role.sts_endpoint` are http or https URLs with a host, and without user info, a query or a fragment; other values fail with `INVALID_ARGUMENT`. With `assume_role`, the key pair signs AssumeRole on the storage's STS, and Unity Catalog vends short-lived credentials scoped to the requested path and privilege. Without it, the server property `server.s3-compatible-storage.static-key-vending` decides what clients receive: * `endpoint-only` (default): the S3 endpoint and region, but no keys; engines bring their own. * `static-key`: the key pair itself. It is not scoped to the requested path or privilege, and changing Unity Catalog permissions does not revoke a key pair already vended. Vends with keys (`assume_role` sessions and `static-key` key pairs) suit only servers whose clients all read `s3_endpoint`: a client that does not would send the keys to AWS S3. Without `assume_role`, in both modes the vended `expiration_time` is a refetch time an hour ahead, not when the keys expire, and the Iceberg REST table config of a `static-key` vend carries no expiration. A running client need not fetch again then; the UC Hadoop connector picks up a changed endpoint on its first table load after `expiration_time`. The external locations of an `s3_compatible` credential must be `s3://` paths. Paths stay `s3://<bucket>/<path>` everywhere: a path reaches the storage of the credential of the external location covering it, so one bucket name can be on several storage systems under different, non-overlapping locations.
Creates a new credential. The type of credential to be created is determined by the **purpose** field. Set exactly one of `aws_iam_role`, `s3_compatible` and `gcp_service_account_key`; otherwise the request fails with `INVALID_ARGUMENT`. A `gcp_service_account_key` credential holds a Google Cloud service account key: the server encrypts its `private_key` with `server.credential-encryption-key` and never returns it, and its external locations must be `gs://` paths. For now it is only stored: a request for access under such a location fails with `UNIMPLEMENTED`. EXPERIMENTAL: `s3_compatible` is available only when the server property `server.s3-compatible-storage.enabled` is `true`. Otherwise a create or update request that sets `s3_compatible`, and vending for a path under one, fail with `INVALID_ARGUMENT`; other updates, reads, lists and deletes of existing ones still work. An `s3_compatible` credential holds an access key pair of S3-compatible storage and the storage's S3 endpoint. `s3_endpoint` and `assume_role.sts_endpoint` are http or https URLs with a host, and without user info, a query or a fragment; other values fail with `INVALID_ARGUMENT`. With `assume_role`, the key pair signs AssumeRole on the storage's STS, and Unity Catalog vends short-lived credentials scoped to the requested path and privilege. Without it, the server property `server.s3-compatible-storage.static-key-vending` decides what clients receive: * `endpoint-only` (default): the S3 endpoint and region, but no keys; engines bring their own. * `static-key`: the key pair itself. It is not scoped to the requested path or privilege, and changing Unity Catalog permissions does not revoke a key pair already vended. Vends with keys (`assume_role` sessions and `static-key` key pairs) suit only servers whose clients all read `s3_endpoint`: a client that does not would send the keys to AWS S3. Without `assume_role`, in both modes the vended `expiration_time` is a refetch time an hour ahead, not when the keys expire, and the Iceberg REST table config of a `static-key` vend carries no expiration. A running client need not fetch again then; the UC Hadoop connector picks up a changed endpoint on its first table load after `expiration_time`. The external locations of an `s3_compatible` credential must be `s3://` paths. Paths stay `s3://<bucket>/<path>` everywhere: a path reaches the storage of the credential of the external location covering it, so one bucket name can be on several storage systems under different, non-overlapping locations.

### Parameters

Expand Down Expand Up @@ -128,7 +128,7 @@ No authorization required

Update a credential

Updates a credential. The caller must be a metastore admin, the credential owner, or have MANAGE on the credential. Set at most one of `aws_iam_role` and `s3_compatible`; setting both fails with `INVALID_ARGUMENT`. Either one replaces the stored credential as a whole, with no field-level merge, and can change its type: an `s3_compatible` update carries `secret_access_key` again, and leaving out `assume_role` removes it. Updates without either, such as of the name or comment, keep the stored credential. EXPERIMENTAL: whoever may update a credential is trusted with where the data under it lives. Changing `s3_endpoint` of an `s3_compatible` credential moves data access for every path under its external locations, including tables and volumes other principals own, to the new host; changing `sts_endpoint` moves where their credentials are issued. The server itself connects to both endpoints. An `s3_compatible` credential has only `s3://` external locations: setting `s3_compatible` while a location outside `s3://` uses the credential, or creating or updating such a location to use it, fails with `INVALID_ARGUMENT`.
Updates a credential. The caller must be a metastore admin, the credential owner, or have MANAGE on the credential. Set at most one of `aws_iam_role` and `s3_compatible`; setting both fails with `INVALID_ARGUMENT`. Either one replaces the stored credential as a whole, with no field-level merge, and can change its type: an `s3_compatible` update carries `secret_access_key` again, and leaving out `assume_role` removes it. Updates without either, such as of the name or comment, keep the stored credential. A `gcp_service_account_key` credential cannot change its type or private key through this endpoint. Its name and comment can still be updated. EXPERIMENTAL: whoever may update a credential is trusted with where the data under it lives. Changing `s3_endpoint` of an `s3_compatible` credential moves data access for every path under its external locations, including tables and volumes other principals own, to the new host; changing `sts_endpoint` moves where their credentials are issued. The server itself connects to both endpoints. An `s3_compatible` credential has only `s3://` external locations: setting `s3_compatible` while a location outside `s3://` uses the credential, or creating or updating such a location to use it, fails with `INVALID_ARGUMENT`.

### Parameters

Expand Down
4 changes: 2 additions & 2 deletions api/Apis/ExternalLocationsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ All URIs are relative to *http://localhost:8080/api/2.1/unity-catalog*

Create an external location

Creates a new external location entry in the metastore. The caller must be a metastore admin to be able to create external locations. EXPERIMENTAL: a location whose credential is `s3_compatible` must have an `s3://` URL; otherwise the request fails with `INVALID_ARGUMENT`.
Creates a new external location entry in the metastore. The caller must be a metastore admin to be able to create external locations. A location whose credential is `gcp_service_account_key` must have a `gs://` URL, and (EXPERIMENTAL) one whose credential is `s3_compatible` must have an `s3://` URL; otherwise the request fails with `INVALID_ARGUMENT`.

### Parameters

Expand Down Expand Up @@ -129,7 +129,7 @@ No authorization required

Update an external location

Updates an external location in the metastore. The caller must be a metastore admin, the external location owner, or have MANAGE on the external location. Unless force is true, changing the url fails if the location is in use (as described for deleting it), unless the new url is the same as, or a parent of, the old one. EXPERIMENTAL: a location whose credential is `s3_compatible` must have an `s3://` URL; otherwise the request fails with `INVALID_ARGUMENT`.
Updates an external location in the metastore. The caller must be a metastore admin, the external location owner, or have MANAGE on the external location. Unless force is true, changing the url fails if the location is in use (as described for deleting it), unless the new url is the same as, or a parent of, the old one. A location whose credential is `gcp_service_account_key` must have a `gs://` URL, and (EXPERIMENTAL) one whose credential is `s3_compatible` must have an `s3://` URL; otherwise the request fails with `INVALID_ARGUMENT`.

### Parameters

Expand Down
1 change: 1 addition & 0 deletions api/Models/CreateCredentialRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| **comment** | **String** | Comment associated with the credential. | [optional] [default to null] |
| **aws\_iam\_role** | [**AwsIamRoleRequest**](AwsIamRoleRequest.md) | | [optional] [default to null] |
| **s3\_compatible** | [**S3CompatibleRequest**](S3CompatibleRequest.md) | | [optional] [default to null] |
| **gcp\_service\_account\_key** | [**GcpServiceAccountKeyRequest**](GcpServiceAccountKeyRequest.md) | | [optional] [default to null] |
| **purpose** | [**CredentialPurpose**](CredentialPurpose.md) | | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
Expand Down
1 change: 1 addition & 0 deletions api/Models/CredentialInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
| **name** | **String** | The credential name. The name must be unique within the metastore. | [optional] [default to null] |
| **aws\_iam\_role** | [**AwsIamRoleResponse**](AwsIamRoleResponse.md) | | [optional] [default to null] |
| **s3\_compatible** | [**S3CompatibleResponse**](S3CompatibleResponse.md) | | [optional] [default to null] |
| **gcp\_service\_account\_key** | [**GcpServiceAccountKeyResponse**](GcpServiceAccountKeyResponse.md) | | [optional] [default to null] |
| **comment** | **String** | Comment associated with the credential. | [optional] [default to null] |
| **owner** | **String** | Username of current owner of credential. | [optional] [default to null] |
| **full\_name** | **String** | The full name of the credential. | [optional] [default to null] |
Expand Down
11 changes: 11 additions & 0 deletions api/Models/GcpServiceAccountKeyRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# GcpServiceAccountKeyRequest
## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
| **email** | **String** | The email of the Google Cloud service account. | [default to null] |
| **private\_key\_id** | **String** | The ID of the service account key. | [default to null] |
| **private\_key** | **String** | The PEM-encoded PKCS#8 private key of the service account key. Write-only; never returned. | [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

10 changes: 10 additions & 0 deletions api/Models/GcpServiceAccountKeyResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# GcpServiceAccountKeyResponse
## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
| **email** | **String** | The email of the Google Cloud service account. | [default to null] |
| **private\_key\_id** | **String** | The ID of the service account key. | [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

2 changes: 2 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ All URIs are relative to *http://localhost:8080/api/2.1/unity-catalog*
- [FunctionParameterMode](./Models/FunctionParameterMode.md)
- [FunctionParameterType](./Models/FunctionParameterType.md)
- [GcpOauthToken](./Models/GcpOauthToken.md)
- [GcpServiceAccountKeyRequest](./Models/GcpServiceAccountKeyRequest.md)
- [GcpServiceAccountKeyResponse](./Models/GcpServiceAccountKeyResponse.md)
- [GenerateTemporaryModelVersionCredential](./Models/GenerateTemporaryModelVersionCredential.md)
- [GenerateTemporaryPathCredential](./Models/GenerateTemporaryPathCredential.md)
- [GenerateTemporaryTableCredential](./Models/GenerateTemporaryTableCredential.md)
Expand Down
67 changes: 61 additions & 6 deletions api/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1247,8 +1247,13 @@ paths:
summary: Create a credential
description: |-
Creates a new credential. The type of credential to be created is determined by the **purpose** field.
Set exactly one of `aws_iam_role` and `s3_compatible`; otherwise the request fails with
`INVALID_ARGUMENT`.
Set exactly one of `aws_iam_role`, `s3_compatible` and `gcp_service_account_key`; otherwise the
request fails with `INVALID_ARGUMENT`.

A `gcp_service_account_key` credential holds a Google Cloud service account key: the server

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (not a blocker): Without a gate, a release containing only this layer offers a GCP credential that cannot serve data

s3_compatible is marked EXPERIMENTAL and gated by server.s3-compatible-storage.enabled. gcp_service_account_key is available on every server, but in this layer vending under its locations returns UNIMPLEMENTED.

The repository guide says an API addition is hard to remove once added.

For example: If this PR is released before [Server] Vend GCS credentials from storage credentials (#2273), admins can create credentials and bind gs:// locations that every read fails on. The request fields and the stored blob layout also become a compatibility surface before vending has used them.

Evidence

The spec says the new type is only stored and that vending fails UNIMPLEMENTED. s3_compatible, right after it, is EXPERIMENTAL and gated by a server property. I found no gate for GCP in CredentialRepository (lines 68 and 163 check only s3_compatible). AGENTS.md says additions are hard to remove.

How it was checked

Checked by 1 independent check: NITPICK

Is the plan to merge this together with #2273 in the same release, or would an EXPERIMENTAL note or a gate be worth adding until then?

encrypts its `private_key` with `server.credential-encryption-key` and never returns it, and
its external locations must be `gs://` paths. For now it is only stored: a request for access
under such a location fails with `UNIMPLEMENTED`.

EXPERIMENTAL: `s3_compatible` is available only when the server property
`server.s3-compatible-storage.enabled` is `true`. Otherwise a create or update request that
Expand Down Expand Up @@ -1371,6 +1376,9 @@ paths:
and leaving out `assume_role` removes it. Updates without either, such as of the name or
comment, keep the stored credential.

A `gcp_service_account_key` credential cannot change its type or private key through this
endpoint. Its name and comment can still be updated.

EXPERIMENTAL: whoever may update a credential is trusted with where the data under it lives.
Changing `s3_endpoint` of an `s3_compatible` credential moves data access for every path
under its external locations, including tables and volumes other principals own, to the new
Expand Down Expand Up @@ -1419,8 +1427,9 @@ paths:
summary: Create an external location
description: |
Creates a new external location entry in the metastore. The caller must be a metastore admin to be able to create external locations.
EXPERIMENTAL: a location whose credential is `s3_compatible` must have an `s3://` URL;
otherwise the request fails with `INVALID_ARGUMENT`.
A location whose credential is `gcp_service_account_key` must have a `gs://` URL, and
(EXPERIMENTAL) one whose credential is `s3_compatible` must have an `s3://` URL; otherwise
the request fails with `INVALID_ARGUMENT`.
operationId: createExternalLocation
requestBody:
required: true
Expand Down Expand Up @@ -1526,8 +1535,9 @@ paths:
or have MANAGE on the external location.
Unless force is true, changing the url fails if the location is in use (as described for
deleting it), unless the new url is the same as, or a parent of, the old one.
EXPERIMENTAL: a location whose credential is `s3_compatible` must have an `s3://` URL;
otherwise the request fails with `INVALID_ARGUMENT`.
A location whose credential is `gcp_service_account_key` must have a `gs://` URL, and
(EXPERIMENTAL) one whose credential is `s3_compatible` must have an `s3://` URL; otherwise
the request fails with `INVALID_ARGUMENT`.
operationId: updateExternalLocation
requestBody:
required: true
Expand Down Expand Up @@ -3015,6 +3025,8 @@ components:
$ref: '#/components/schemas/AwsIamRoleResponse'
s3_compatible:
$ref: '#/components/schemas/S3CompatibleResponse'
gcp_service_account_key:
$ref: '#/components/schemas/GcpServiceAccountKeyResponse'
comment:
description: Comment associated with the credential.
type: string
Expand Down Expand Up @@ -3058,6 +3070,8 @@ components:
$ref: '#/components/schemas/AwsIamRoleRequest'
s3_compatible:
$ref: '#/components/schemas/S3CompatibleRequest'
gcp_service_account_key:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (not a blocker): Typed UI callers cannot send or read a GCP credential

The OpenAPI spec defines the field on both create and response models. The catalog types checked into the UI still omit it from both.

For example: A CreateCredentialRequest literal with gcp_service_account_key produces TS2353. Accessing the field on CredentialInfo produces TS2339, so both sides of a typed create call fail to compile.

Optionally regenerate ui/src/types/api/catalog.gen.ts with the existing generate:catalog script (bunx openapi-typescript), in a separate housekeeping PR. That catches up s3_compatible as well. Never hand-edit the file.

Evidence

The catalog spec adds the field on requests and responses. The checked-in TypeScript schema omits it from both. Compiling an object literal produced TS2353, and reading the response property produced TS2339. The UI package defines the generator for this exact spec and output path.

How it was checked

Reproduced: node /tmp/gcp-gate-4102/ts442/package/bin/tsc --noEmit --skipLibCheck --lib es2020,dom ui/src/types/api/catalog.gcp.test.ts (TypeScript 4.4.2, the version pinned in ui/package.json)

head:

Version 4.4.2
ui/src/types/api/catalog.gcp.test.ts(8,3): error TS2322: Type '{ name: string; gcp_service_account_key: {}; }' is not assignable to type '{ name: string; comment?: string; aws_iam_role?: { role_arn: string; }; purpose?: CredentialPurpose; }'.
  Object literal may only specify known properties, and 'gcp_service_account_key' does not exist in type ...
ui/src/types/api/catalog.gcp.test.ts(12,15): error TS2339: Property 'gcp_service_account_key' does not exist on type '{ name?: string; aws_iam_role?: {...}; comment?: string; owner?: string; ... purpose?: CredentialPurpose; }'.
exit=2

with the fix:

Control: the same fixture using aws_iam_role instead of gcp_service_account_key compiles with exit=0. The regenerated-types fix was not run, because it needs bun and openapi-typescript.

Checked by 2 independent checks, which split: CONTESTED, DISPROVED

Could the catalog types be regenerated alongside the API models?

$ref: '#/components/schemas/GcpServiceAccountKeyRequest'
purpose:
$ref: "#/components/schemas/CredentialPurpose"
UpdateCredentialRequest:
Expand Down Expand Up @@ -3192,6 +3206,47 @@ components:
'_' and '-'. If not set, the region of the S3-compatible storage holding the requested
path is used.
type: string
GcpServiceAccountEmail:
description: The email of the Google Cloud service account.
type: string
Comment thread
timothyw553 marked this conversation as resolved.
Resolved
maxLength: 1024
GcpPrivateKeyId:
description: The ID of the service account key.
type: string
maxLength: 1024
GcpServiceAccountKeyRequest:
description: |
A key of a Google Cloud service account with access to Google Cloud Storage. Set `email`
from the key file's `client_email`, and copy `private_key_id` and `private_key`. Its
locations must be `gs://` paths. The server stores `private_key` encrypted with
`server.credential-encryption-key`, so it cannot create one without that key. It checks the
fields and that the private key parses, not that Google accepts the key.
type: object
required:
- email
- private_key_id
- private_key
properties:
email:
$ref: "#/components/schemas/GcpServiceAccountEmail"
private_key_id:
$ref: "#/components/schemas/GcpPrivateKeyId"
private_key:
description: The PEM-encoded PKCS#8 private key of the service account key. Write-only; never returned.
Comment thread
timothyw553 marked this conversation as resolved.
Resolved

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (not a blocker): A correctly encoded non-RSA key gets an encoding error

The API calls for PKCS#8 PEM, while the parser specifically expects RSA. The schema also marks email and private_key_id required without describing the nonblank check. The request documentation omits conditions the server enforces. This is one bug class: Validator requirements stricter than the schema (RSA only, non-blank identifiers) are missing from the spec, and the catch-all error names the wrong cause. The same issue appears in server/src/main/java/io/unitycatalog/server/persist/dao/CredentialDAO.java:522 (A valid EC PKCS#8 key gets 'is not a PEM-encoded PKCS#8 private key', which is wrong for that caller.); api/all.yaml:3209 (GcpServiceAccountEmail and GcpPrivateKeyId are plain required strings. The schema does not say they must be non-blank, but the validator rejects whitespace-only).

For example: The pinned parser rejects a generated EC key encoded as PKCS#8 PEM. UC then says it is not a PEM-encoded PKCS#8 private key, which points the caller toward re-encoding the same key.

Specify a PEM-encoded PKCS#8 RSA private key, describe both identifiers as nonblank, regenerate the model docs and align the invalid-key diagnostic.

Evidence

I checked the create-operation description, GCP component schemas and generated model page. They describe required strings and a PEM-encoded PKCS#8 key. The DAO also rejects whitespace-only identifiers and uses an RSA-specific parser. With a generated EC key in PKCS#8 PEM, the pinned parser threw IOException, which the DAO translates into a claim that the encoding is wrong.

How it was checked

Reproduced: dev/run-tests.py "server/testOnly io.unitycatalog.server.persist.dao.CredentialDAOTest"

head:

[error] Test io.unitycatalog.server.persist.dao.CredentialDAOTest.testGateEcPkcs8Contract failed: java.lang.AssertionError:
[error] Failed: Total 9, Failed 1, Errors 0, Passed 8
CredentialDAOTest#testGateEcPkcs8Contract(): java.lang.AssertionError: Expecting throwable message: "gcp_service_account_key.private_key is not a PEM-encoded PKCS#8 private key." to contain: "RSA" but did not. (at CredentialDAO.validateGcpServiceAccountKey(CredentialDAO.java:309))

Checked by 1 independent check: CONFIRMED

References:

Could we name RSA in the field description and error, and make the nonblank identifier requirement explicit?

type: string
maxLength: 4096
writeOnly: true
GcpServiceAccountKeyResponse:
description: The service account key of a `gcp_service_account_key` credential, without its write-only `private_key`.
type: object
required:
- email
- private_key_id
properties:
email:
$ref: "#/components/schemas/GcpServiceAccountEmail"
private_key_id:
$ref: "#/components/schemas/GcpPrivateKeyId"
ListCredentialsResponse:
type: object
properties:
Expand Down
Loading
Loading