Skip to content

[Server] Vend GCS tokens from storage credentials - #2181

Draft
timothyw553 wants to merge 3 commits into
unitycatalog:mainfrom
timothyw553:stack/gcs-credential-vending
Draft

timothyw553 wants to merge 3 commits into
unitycatalog:mainfrom
timothyw553:stack/gcs-credential-vending

Conversation

@timothyw553

@timothyw553 timothyw553 commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Part of #47 (the roadmap item covers GCP at S3 parity alongside Azure). PR 3 of 4 in a stack; depends on PR 2:

  1. [Server] Add Azure service principal and GCP service account key credentials #2179 [Server] Add Azure service principal and GCP service account key credentials
  2. [Server] Vend Azure SAS tokens from storage credentials #2180 [Server] Vend Azure SAS tokens from storage credentials
  3. this PR: GCS vending
  4. [Docs] Point cloud storage setup at credentials and external locations #2182 [Docs] Point cloud storage setup at credentials and external locations

Motivation

A path under an external location whose credential is a GCP service account key returned UNIMPLEMENTED; only the legacy gcs.* per-bucket configuration in server.properties could vend for GCS.

Changes

  • GcpCredentialVendor signs in with the storage credential's service account key and issues an OAuth token downscoped to the requested path and privileges, through the same generator and credential access boundary as the per-bucket configuration, which stays the fallback for paths no external location covers. The generator now takes a credentials source (stored key, key file, or application default credentials) instead of a file path.
  • New ServiceAccountKeys.parse turns the stored key into ServiceAccountCredentials. CredentialRepository calls it on create and update, so a private_key that is not PEM-encoded PKCS#8 is rejected with INVALID_ARGUMENT instead of being stored and failing at vend time.
  • CachingCloudCredentialVendor binds a GCP credential by service account email and private key ID.
  • CredentialDAO.getGcpServiceAccountKey() exposes the stored key to the vendor only.

Docs

  • New docs/server/gcp.md ("Deploy for GCP"), mirroring the AWS page: service account and roles (roles/storage.objectAdmin / objectViewer), key file, credential and external location creation through the CLI, key rotation, migration from gcs.* configuration, and the impersonation limitation.
  • docs/server/configuration.md describes the GCP cache binding.

Tests

  • ServiceAccountKeysTest: a generated RSA key round-trips (email, key ID, DER bytes); non-key text is rejected.
  • GcpCredentialVendorTest: the stored key is used (per-bucket config not consulted), another cloud's credential is rejected, and without a credential the bucket must be configured.
  • CachingCloudCredentialVendorTest: email and key ID changes get separate cache entries.
  • BaseCredentialCRUDTest now creates GCP credentials with a generated PEM key (TestUtils.generatePkcs8PrivateKeyPem) and checks a malformed key is rejected at create time.
  • Full server/test and cli/test pass locally. No real-GCS end-to-end run (no GCP project available here).

Compatibility

No API change. Per-bucket gcs.* behavior is unchanged. Tightening from PR 1: a gcp_service_account_key whose private key cannot be parsed is now rejected at create time.

This pull request and its description were written by Isaac.

timothyw553 and others added 3 commits November 11, 2026 19:08
…entials

Storage credentials only accepted aws_iam_role, so ADLS and GCS storage
could be reached only through the legacy adls.* and gcs.* entries in
server.properties, which need a service maintainer and a restart and
keep cloud secrets on the server host. Part of unitycatalog#47.

Add azure_service_principal {directory_id, application_id, client_secret}
and gcp_service_account_key {email, private_key_id, private_key} to the
credential API, with the same names as Databricks Unity Catalog, store
them in the existing typed JSON blob of uc_credentials, and return the
identity without the secret on get and list.

A create request must carry exactly one cloud identity and an update at
most one, and the cloud cannot change afterwards: external locations
bind a credential to URLs of its cloud, so creating or updating an
external location now rejects a credential that cannot reach the URL
(file: URLs accept any). The CLI gets --azure_directory_id,
--azure_application_id, --azure_client_secret and
--gcp_service_account_key_file.

uc_credentials.credential_type is an enum (H2, MySQL) or a check
constraint (PostgreSQL) in the versioned schema, so schema step V3 widens
it to the new values; an existing database takes it through
bin/start-uc-server --upgrade-schema. The effect files come from
build/sbt updateSchemaDumps on all three databases.

Vending through these credentials still returns UNIMPLEMENTED; the next
PRs in the stack add it for Azure and GCS.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
A path under an external location whose credential is an Azure service
principal returned UNIMPLEMENTED; only the legacy adls.* per-account
configuration in server.properties could vend for ADLS. Part of unitycatalog#47.

The Azure vendor now signs in as the storage credential's service
principal and issues a user delegation SAS scoped to the requested path,
as it already did for the per-account configuration, which stays the
fallback for paths no external location covers. Like the AWS master role
assuming the storage role, the sign-in happens on every vend, so a
rotated client secret takes effect immediately.

The server credential cache keys an entry on the credential's cloud
identity: the role ARN and external ID for AWS, and the application and
directory ID for Azure, so a credential moved to another service
principal is never served a cached token. A GCP storage credential still
fails as before; the next PR adds it.

Docs: a "Deploy for Azure" guide mirroring the AWS one, with the
migration from adls.* configuration, and the cache binding for Azure in
the configuration page.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>
A path under an external location whose credential is a GCP service
account key returned UNIMPLEMENTED; only the legacy gcs.* per-bucket
configuration in server.properties could vend for GCS.

The GCP vendor now signs in with the storage credential's service
account key and issues an OAuth token downscoped to the requested path,
as it already did for the per-bucket configuration, which stays the
fallback for paths no external location covers. The private key is
parsed when a credential is created or updated, so a key that cannot
vend is rejected with INVALID_ARGUMENT instead of being stored. The
server credential cache binds a GCP credential by its service account
email and private key ID.

Docs: a "Deploy for GCP" guide mirroring the AWS one, with the migration
from gcs.* configuration, and the cache binding for GCP in the
configuration page.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant