Repository navigation
Iceberg on Google: a Google identity for REST catalogs, a per-source storage identity with a GCS reader, and one codec for every surface - #2196
Conversation
A graph source could reach a Google catalog (BigLake) only as the GCE metadata server's service account. That rules out every host that is not on Google, and a hosted stack where each tenant needs its own identity. GoogleCredentials names four sources: the metadata server, a service-account key, Workload Identity Federation from AWS, and the host's application-default credentials. All four are served by one GoogleIdentity. AuthConfig::Google uses it, and the stored google_metadata variant keeps reading and round-tripping unchanged. The providers are written here, over the hardened HTTP client, instead of taking google-cloud-auth: tenant-supplied credential JSON can name arbitrary token endpoints, files, URLs and executables. Only a validated subset is accepted. Credential sources must be AWS. STS, impersonation and OAuth endpoints must be Google's own. The metadata URL is pinned (an operator override only). Tokens are cached process-wide and refreshed single-flight with a margin; a still-valid token survives a failed refresh. The cache key includes the AWS subject that signed a WIF exchange, so two tenants who paste the same WIF config never share a token. It also includes a digest of a service account's private key, so a key that only names another tenant's service account never gets that tenant's token. CatalogAuth::request_headers replaces authorization_header so the quota project (x-goog-user-project) reaches every caller: the REST catalog, the SQL source and Unity. Google's missing-quota-project 403 is typed with the fix. Host-derived identities (ambient AWS, the metadata server, host ADC, host-signed WIF) are now an operator decision. HostIdentityPolicy reads FLUREE_GRAPH_SOURCE_HOST_IDENTITIES (default all) and fails closed on a value it cannot parse. It is set per Fluree instance, and the server reads it from the environment. An embedder can supply per-tenant AWS subject credentials for WIF, and those are not gated by the policy. Both travel in one IdentityContext to every place a provider is built, and the api's client caches include the context in their keys, so a client built for one tenant never serves another. IoConfig.storage_auth (vended | ambient | catalog | google) is defined and validated here; reads use it in a later phase. Absent means what vended_credentials always meant, and the two may not contradict each other.
A token exchange Google refused, invalid Google credentials, a host identity the policy refuses, and a catalog that needs a quota project used to fall into the generic wrappers: Internal (500) on the query path, Config (400) on preview. A client could not tell "this identity lacks a grant" from a server fault, and hosts went back to classifying by message text. Each one is now typed on the query, preview and provider-construction paths, through one helper all three share, and survives the lazy storage builder's IcebergError channel. The codes: err:auth/GoogleTokenExchange (403 when Google said 403, 502 when Google failed or never answered, otherwise 401), err:auth/GoogleCredentialsInvalid (400), err:auth/HostIdentityRefused (403), err:catalog/QuotaProjectRequired (403). The messages carry Google's error code, never a response body.
Pins three things. The instance's host-identity policy governs the catalog auth built on the query path (shared_catalog_client) and on the onboarding path (browse). It is set on the instance or on the builder. A refusal is a typed 403 before any request is made. Clones carrying a policy or an AWS subject leave the original alone, and their contexts key the shared client caches apart. Re-exports aws_credential_types::Credentials as AwsCredentials, so an embedder implements AwsSubjectCredentials against the same version without a dependency of its own.
wiremock pools its mock servers, so a test's server URL can be one an earlier test used. The Google token cache keys on endpoints, so a reused URL let one test be handed another's cached token. The REST route-prefix cache is keyed by URL + warehouse, so a reused URL could also inherit another test's prefix. A serial run of the iceberg lib tests failed this way. Test endpoints now carry a token-cache partition of their own (empty in production, so no production key changes), and the new REST tests use warehouses no other test does. Five of the existing REST tests fail the same way under --test-threads=1 on main as well. They are left as they are.
A cached Google token is keyed on an identity that a secret proves, and
the key now includes that secret wherever there is one, hashed and held
in memory only: a service account's private key, and the ADC file's
refresh token and client secret. The ADC file is read before the cache
is consulted, so a new gcloud login for the same account is exchanged
instead of being served the token the old refresh token minted. A file
that changed identity is still refused. sha2 becomes unconditional
because user ADC works without the `aws` feature.
A WIF config object that mixes reference keys (secret_ref, env_var, ...)
with an inline configuration's `type` is now refused as ambiguous instead
of being read as inline.
A build without request signing refuses service-account and WIF
credentials with the typed GoogleCredentialsInvalid ("not available in
this build") instead of a generic config error.
Also pins that clones of one Fluree with different AWS subjects or
policies never share a catalog client, while one context gets its
cached client back.
The SQL and Delta sources take their auth from the same AuthConfig as Iceberg, so they meet the same identity refusals: a Google token exchange refused, invalid Google credentials, a host identity the policy refuses. Both flattened them into strings (SqlError::Auth, DeltaError::Config / Catalog). A refused identity then answered 500 on a query, or 400 err:config on the admin paths, while an Iceberg source answered with its own code. SqlError::Identity and DeltaError::Identity now carry the refusal typed. Delta also recovers it from the object store's credential provider, where a vended-credential renewal fails, so the refusal survives that path too. The api lifts both through the same mapping the Iceberg paths use, giving the same wire codes (err:auth/*, err:catalog/QuotaProjectRequired) and statuses. That covers a SQL query's client and scans, the SQL connection test and check, a Delta query's Unity table, and Delta onboarding. IcebergError gains is_identity_refusal() (the one list of these refusals) and Clone, so a refusal lent out by an error chain can be recovered intact. Also pins that IoConfig::with_storage_auth sets vended_credentials to agree, so only hand-written JSON meets the contradiction check, and documents why an ADC identity is not bound at construction.
The REST catalog tests failed under --test-threads=1, on main as well. MockServer::start() hands out pooled servers, so a test can be given a URL an earlier test used. The route-prefix cache (lock_prefixes) is process-wide and keyed by catalog URL + warehouse, so such a test was answered with the earlier test's cached prefix (/v1/p, /v1) and loaded a route it never served. Five tests failed this way; the parallel default run hid it by handing concurrent tests different servers. Every test in the module now starts an unpooled server (MockServer::builder().start()), on a port of its own. Test-only: production code is untouched.
… identity The storage layer could read object stores only through the S3 SDK with the host's AWS chain or vended S3 keys. A BigLake runtime catalog vends gcs.oauth2.token, which parsed as "vended nothing", and gs:// was read by any S3 client as s3://same-name on AWS. VendedCredentials is now S3 keys or a GCS token. Both expiry spellings (gcs.oauth2.token-expires-at, gcs.oauth2.token_expires_at) parse, the gcs token keys join CREDENTIAL_KEYS so a top-level token never stands in for a matched entry, and a token without an expiry is refused. GcsIcebergStorage reads gs:// through object_store's GCS backend (0.13.2, the version Delta Kernel already links), behind one shim module. It is built only with GoogleCloudStorageBuilder::new and an explicit credential provider, never from_env, so it cannot fall back to host ADC or the metadata server. Tokens come from a GoogleIdentity minted for devstorage.read_only, or a vended token. A 401 renews the token and retries once; a 403 is StorageAccessDenied. The endpoint is Google's unless the operator sets FLUREE_GCS_ENDPOINT. Vended credentials renew inside the store. RenewingVendedCredentials re-vends single-flight inside a margin before expiry, through the catalog's per-table credentials endpoint (SendCatalogClient::load_credentials, with a loadTable fallback), and keeps a still-valid credential when renewal fails. The GCS reader and, through the existing VendedAwsCredentialProvider, the S3 client both use it, so a scan that outlives one token keeps reading. Each backend refuses a path outside the schemes it serves (err:storage/SchemeNotServed): S3 reads gs:// only through Google's interop endpoint, GCS reads only gs://. An S3 client can carry the operator's ambient-bucket allowlist. from_default_chain is deprecated and hidden: graph sources get their storage from the decision Fluree applies, which the next change adds. StorageScope fingerprints the identity a read was made under. The Parquet data-file cache, and so its single-flight fill, now key on it; the shared scope keeps the file names caches had before. The footer cache needs none because a footer is served only after the store answers the file's size, which a test now pins. The API call sites are adapted mechanically here and rebuilt on one storage constructor next.
…rves Direct mode accepted only s3://, s3a:// and local table locations, so a catalog-less table on GCS could not be registered even with a Google storage identity, the case io.storage_auth `google` exists for. A gs:// table location is now accepted when the source's identity reads gs://: a Google identity, or ambient AWS through Google's S3 interop endpoint. Anything else is refused at registration, not at the first read. The table identifier is derived from a gs:// location as from an s3:// one.
…orage Storage for an Iceberg graph source was built in five places from one boolean (vended or ambient), with no policy on the host's identity, and the location-keyed caches served every source from one key space. Fluree::graph_source_storage(config, grant) is now the one constructor. plan_storage decides the identity from the source's configuration (io.storage_auth, else what vended_credentials always meant), applies the instance's HostIdentityPolicy (the `aws` kind and its bucket allowlist; the Google host kinds where a Google identity is built), binds the identity to the schemes it serves (err:storage/SchemeNotServed), proves a Google identity by minting a storage token, and fixes the StorageScope every cache is keyed by, all before any cache is consulted. StoragePlan::build makes the store from the opaque CatalogGrant: vended S3 keys or a GCS token that renew through the catalog's credentials endpoint, the catalog's or the source's Google identity over the GCS reader, ambient AWS, or the local filesystem. ResolvedStorage carries the store, a #[non_exhaustive] StorageDecision and the scope. §2 is part of the plan: a vended source granted nothing is refused, before a query reuses a store it built. The query path (eager and pointer rungs), materialize, the /info row counts, preview, verify, sample and the provisional query all build through it. The native-AWS catalog clients (Glue, S3 Tables) call AWS with the host chain, so they are the `aws` host identity too. The in-memory table_metadata, scan_files and direct_metadata_locations layers, and the disk metadata, scanfiles and countstats layers, key on the scope; the default configuration (ambient, no endpoint, the default identity context) keeps the bare key and the literal `shared` segment, so existing entries stay warm. The cross-query loadTable key, which caches vended credentials and is shared by every clone of a Fluree, carries a non-default identity context too. Browse, preview, verify and sample ran as free functions under the default identity context, which allows every host identity: an embedder calling them bypassed its own policy, and generate and validate called the free preview internally. The free functions are removed; the Fluree methods, which use the instance's context, are the only public forms.
Through the query path itself: two REST sources whose catalogs grant different identities point at one metadata location. The pointer rung serves the cached metadata only to the identity that read it, and the COUNT(*) shortcut its manifest stats; the other identity goes to its catalog. An explicitly ambient source builds the host's AWS client whatever the catalog vended.
The verify probe, the sampler, the provisional query and the catalog client still named helpers the storage constructor replaced. They now name the decision itself, and the probe's credential_source lists the identities it can report.
…nfig HTTP, the CLI and Python each translated their own flat fields into AuthConfig / IoConfig / Delta auth, about eighteen functions that had drifted: Google auth reached only /iceberg/map, partial OAuth2 was dropped silently for Iceberg and SQL but refused for Delta, precedence between auth modes differed per kind, and an Azure secret variable skipped the server's allowlist. graph_source::surface is now the one path. Structured input is the stored JSON, checked strictly by re-serializing the parsed value and refusing any key it lacks, so the check cannot drift from the persisted types. Legacy flat fields go through one converter per kind, with catalog auth decided by one CatalogAuthFields::into_auth for Iceberg, SQL and Unity. Every ConfigValue is checked against the caller's SecretRules: env allowlist, secret_ref only with a resolver, no literal service-account key, no metadata_url, no default_val/java_property. Refusals are a typed ApiError::GraphSourceInput (400, err:api/InvalidGraphSourceConfig) naming the field. Builders gain with_auth / with_storage_auth; a setting the catalog mode cannot honor is recorded and refused at validate() instead of warned and ignored (the old message said "Direct catalog mode" for Glue too). Registration now runs the engine's full IcebergGsConfig::validate for every mode, storage identity included, and connection validate runs before every catalog read. Direct validation no longer derives a table identifier when a mapping names the tables. Read-outs of stored configs are redacted structurally: one exhaustive walk per auth type (auth::fields) classifies every ConfigValue, the redactor masks the secret ones and every key the type does not know, and a config its type cannot read is withheld whole.
…he codec Each Iceberg route (map, browse, preview, verify, generate, validate), sql/map and every Delta route now keeps only its own fields and hands the rest of the body to the one codec. A request may give the structured catalog / io (Iceberg), auth (SQL) or unity / io (Delta) exactly as the stored config spells them, or the legacy flat fields; an unknown field, the two forms mixed, and auth given two ways or half given are a typed 400 naming the field. What this fixes: - auth_google_metadata reached iceberg/map only. The read-only routes' request type had no such field, so serde dropped it and browse/preview ran with no auth. It now reaches every route. - an Azure secret given as azure_client_secret_env skipped FLUREE_GRAPH_SOURCE_SECRET_ENV_VARS. Every ConfigValue on every route now goes through the allowlist. - SQL secrets were literal-only over HTTP. sql/map gains auth_bearer_env / oauth2_client_secret_env and the structured auth, so a Google identity can authenticate a SQL endpoint. - the SSRF guard read request fields, which a structured body would bypass. It now runs on the parsed config (catalog URI, OAuth2 token URL, S3 endpoint, Unity workspace). Fluree::generate_r2rml and validate_r2rml previewed each table with the free preview_iceberg_table, which builds auth under the default identity context. So the instance's host-identity policy and per-tenant AWS subject never applied to them (a deny-all instance still called the GCE metadata server). They now use the instance's context, as browse/preview/verify already did.
…torage identity iceberg map, sql map and the Delta Unity commands each declared and translated their own auth flags, and they had drifted: SQL secrets were literal-only, OAuth2 activated only on token URL plus secret (a token URL alone registered no auth), and OAuth2 silently beat a bearer token. Three #[command(flatten)] groups replace them, each with one conversion onto the codec every surface uses: - CatalogAuthArgs (bearer / OAuth2, literal or _env): iceberg map, sql map and every Delta command that takes a Unity Catalog. - GoogleAuthArgs: --auth-google-metadata, --auth-google-adc, --auth-google-service-account-env VAR, --auth-google-wif-config FILE (read and stored inline; it is not a secret), --auth-google-quota-project, --auth-google-scopes. For iceberg map and sql map. - StorageIdentityArgs: --storage-identity vended|ambient|catalog|google, plus --storage-google-* for a source's own Google identity (Direct mode on gs://). With no storage flag, a bq:// warehouse defaults to catalog and a bl:// one to vended (the surface chooses; the engine never infers). A bq:// warehouse without a Google catalog identity is refused, naming the flags to use. The flat Iceberg converter moves into the API as IcebergConnectionFields, the one conversion the legacy HTTP fields and these flags share. A refusal names the flag (--oauth2-token-url needs --oauth2-client-secret ...). Remote iceberg map and sql map now send the structured connection their local form would store, built by the same conversion, so local and remote register the same record (pinned by a CLI-to-server seam test). The Delta commands keep sending flat fields, so a CLI built without the delta feature can still drive a server that has it.
…urces
The public layer gains fluree.Google (the metadata server, application-default
credentials, a service-account key named by an EnvVar, or a Workload Identity
Federation configuration as a dict or file) as catalog auth for map_iceberg and
map_sql, and map_iceberg gains `storage` ("vended" / "ambient" / "catalog" or a
Google identity of the source's own). A service-account key is never taken
literally, since it would be stored with the source.
The native layer used to write RestCatalogMode.auth and io.vended_credentials
directly, past the builders. It now goes through them, so a setting the
catalog mode cannot honor is refused by the same rule (and message) as on the
CLI and server. Every auth and storage value is checked against the instance's
SecretRules: secret references only with a resolver, no default_val. Like the
CLI, a bq:// warehouse defaults to storage "catalog" and a bl:// one to
"vended" when the caller names neither storage nor vended_credentials.
…torage identity endpoints.md documents the connection every Iceberg route takes: the structured catalog / io (exactly the stored shape, with every auth, GoogleCredentials and storage_auth variant) beside the legacy flat fields, and the 400s (err:api/InvalidGraphSourceConfig) for an unknown field, the two forms mixed, and auth given two ways or only partly. sql/map gains structured auth and the _env fields, the Delta routes their structured unity / io. The CLI pages document the shared catalog-auth, Google and --storage-identity groups, the bq:// and bl:// defaults, and remote mode sending the structured connection. configuration.md documents FLUREE_GRAPH_SOURCE_HOST_IDENTITIES, FLUREE_GRAPH_SOURCE_AMBIENT_BUCKETS and FLUREE_GOOGLE_METADATA_URL, and widens FLUREE_GRAPH_SOURCE_SECRET_ENV_VARS to every route and value (Azure included). Corrected where the docs disagreed with the code: sql.md said SQL auth values take env_var / secret_ref indirection (HTTP and the CLI took literals only; secret_ref still needs an embedded resolver); server-integration.md said the OAuth2 fields must all be given together (a token URL alone was silently dropped, and is now refused). iceberg.md's Type Mapping table now states what happens today: an rr:column without rr:datatype is an xsd:string literal for every column type. The table is the one place a natural-datatype change has to edit, beside the datatype the generator emits.
The first commit taught IcebergGsConfig::validate to skip the Direct table-identifier derivation when a mapping names the tables. But every query runs that same validate before it reads anything, so the change also loosened query-time validation, which is out of this PR's scope. It is reverted. Registration now runs the unchanged validate, so it refuses a mapped Direct location naming no namespace/table (s3://bucket/dw) that every query would refuse. graph_source_alias_query_does_not_deserialize_as_ledger registered such a location and relied on the query failing at that validate. Its fixture now names a namespace and table, and the query fails on the mapping's own table name, still inside the graph-source engine. Also gates REST_CATALOG_TYPE on the iceberg feature (the wasm32 no-default-features lint caught it unused).
…e default split
Nested nulls were already skipped by the strict check (the canonical form
omits a defaulted Option), but a top-level null beside the other form was
refused as mixing: {"catalog": {...}, "catalog_uri": null}, which a client
serializing every field sends. A null now means absent in either form; a null
cannot hide an unknown key that carries a value.
No persisted type uses #[serde(alias)]. The compat spellings are the untagged
helpers: the legacy catalog with no `type` (read as REST, the shape old records
hold, so a read-out of one can be sent back), a WIF config given as JSON text,
and ConfigValue's three forms. All are accepted, and pinned by tests. The legacy
catalog's read path stays strict about unknown keys.
The docs now say where the bq:// / bl:// storage-identity default lives: the
CLI and Python apply it, and the HTTP routes store exactly what they are sent.
The first commit's message said connection validate() runs before every catalog read, but it ran only at registration. A setting a builder recorded as refused (e.g. with_oauth2_audience with no OAuth2 auth, or a REST-only setting in another mode) was therefore ignored outright by browse, preview, verify, generate, validate and the provisional query, where the old builder had at least warned. So was an io.storage_auth the catalog cannot serve. Fluree::hydrate_conn, the one entry all of them take, now calls IcebergConnectionConfig::validate() before hydrating. The free context-less functions do not (Phase 2a removes them).
GoogleCatalogAuth attached its token to whatever URL the source named: the catalog URI, the SQL endpoint, Unity. A host identity's token is the server's own (the metadata server, the host's gcloud ADC, WIF signed with the host's AWS chain). So under the default policy, browsing `catalog.uri = https://attacker.example` with `application_default` shipped the server's cloud-platform token off-box. This was new for ADC and host-signed WIF, and pre-existing for google_metadata. A host identity's token now goes only to https://googleapis.com and its subdomains (BigLake, BigQuery, Private Service Connect's *.p.googleapis.com), plus hosts the operator lists in FLUREE_GOOGLE_TOKEN_HOSTS (read once, never per source). Any other destination is refused before a token is minted, with GoogleTokenHostRefused naming the host and never the token (403, err:auth/HostIdentityRefused; its own QueryError so the host survives the lazy storage builder). A source's own service-account key, and WIF signed with an embedder's per-tenant subject, still go wherever the source points. The check is enforced where headers are produced: CatalogAuth::request_headers now takes the request URL. A caller cannot obtain a credential without naming its destination, so a new caller cannot forget the check. The REST catalog, every Trino request (each nextUri page and the cancel, since the endpoint names those) and Unity pass theirs. Also from the review: - A server's 401 forces at most one re-mint per cached token every 30 s. Within that window the token is kept and the retry reports the refusal, so one source cannot make a shared host token re-mint constantly. - A token response's expires_in (and impersonation's expireTime) is clamped to 24 h instead of added raw. A huge expires_in from a tenant-chosen OAuth2 token_url panicked. - The ADC principal uses the `account` gcloud records when the file names one; gcloud's client id is the same for every user. The module documents that ADC is one host-global, policy-gated identity.
rustfmt orders the pub use items; the integration branch carried them unformatted, so fmt --check failed before any change here.
The provider decides where a credential may go, by the URL it is given, so each client must give the URL it is about to request. The REST catalog, Unity and Trino each have a test with a recording provider that pins it. Trino's covers the statement and a page at the nextUri the endpoint chose.
…se secrets it resolves HostIdentityKind::Azure (env token `azure`, part of `all`) governs the host's own Azure credentials, which a Delta table with no service principal of its own reads with. A source's own `io.azure` client secret and Unity's per-table credentials are not host identities. SecretResolver::scope_id (default None) names whose secrets a resolver resolves. An embedder whose resolver maps one reference name to different secrets per tenant must return one: it is part of IdentityContext::cache_scope, so every cache keyed by the stored configuration (which carries the reference, not the secret) is also keyed by it. The default context's scope is unchanged. The policy's bucket allowlist is documented as governing storage reads only: an AWS Glue or S3 Tables catalog call is gated by `aws` alone.
…hrough a cache fill
IcebergError::StorageAccessDenied and QueryError::StorageAccessDenied
carry the path's scheme, so a GCS denial prints gs://bucket/key with a
GCS hint, not s3://. The "Storage access denied" prefix hosts match is
kept. The API keeps ApiError::StorageAccessDenied (fields unchanged) for
S3 and lifts any other store's denial as the query variant: the same 403
and STORAGE_ACCESS_DENIED code. The scheme is a &'static str from the
closed set a store reads, which keeps QueryError and ApiError small (a String
made them 120/128 bytes and tripped clippy's result_large_err; now 112 and 120).
A denied data file under the whole-file threshold now surfaces as the
typed denial instead of the flattened "disk-cache fill:" error: the
fill's leader gets the store's own error back (wrapped, not
stringified), and a waiter that only saw the leader's text asks the
store once (a HEAD) and reports the typed denial that comes back.
Also: StorageScope's Debug shows only whether it is the shared scope
(its description carries digests of stored auth), so ResolvedStorage's
Debug prints StorageScope("<scoped>"); the non-aws build no longer
carries a dead env_switch_enabled; rustdoc private-item links and bare
URLs fixed so `cargo doc -D warnings` is clean for the crate.
A GCS store built one object_store client per bucket in an unbounded map, so a table whose manifests name many buckets grew memory and connection pools without limit. It is now an LRU of 64; a dropped client is rebuilt if its bucket is read again.
…cache planned Google identities Under a bucket allowlist (FLUREE_GRAPH_SOURCE_AMBIENT_BUCKETS) an ambient-AWS read through an s3_endpoint override is refused with the typed AmbientEndpointRefused, both when storage is planned and in the store for every path it reads: a virtual-hosted endpoint read path-style names a bucket of its own, so the bucket the path names would not be the bucket read. It maps to HOST_IDENTITY_REFUSED (403). Only a Direct source reads the local filesystem. A REST, Glue or S3 Tables catalog that places a table on this host's disk is refused with LocalLocationFromCatalog (STORAGE_SCHEME_NOT_SERVED), as before storage identities, when every catalog source read through S3. plan_storage now caches the Google identity it builds for `catalog` and `google` storage auth, process-wide, keyed by a digest of the stored config and the identity context's cache scope (the resolver's scope id, the policy, the AWS subject), bounded by the catalog-client TTL. A warm plan no longer resolves the secret, re-parses the key or builds an HTTP client; the token proof still runs on every plan.
…licy governs DeltaTable::open built AmazonS3Builder::from_env and MicrosoftAzureBuilder::from_env with no policy check, so a source registered at s3://<stack-internal-bucket>/t read with the host role even under FLUREE_GRAPH_SOURCE_HOST_IDENTITIES=none. DeltaTable::open (and the store it opens) now requires the IdentityContext: - an s3:// table read with the host's credentials needs `aws`, its bucket on the ambient allowlist, and no endpoint override under one; - an Azure table with no io.azure of its own needs `azure`. The check is at open only: a store is bound to the table's bucket, and Kernel addresses every file, an absolute data-file URL included, as a path within that store (Path::from_url_path drops the host). Fluree::open_delta_table(name, location, io) opens a table the way the instance's graph sources do (io hydrated with its resolver, opened under its context), for embedders that read a table outside a graph source. The Delta handle cache is keyed per graph source as well as by config and identity scope, and resolves the config's secrets before the lookup, so a caller whose resolver refuses them is never served a handle another caller opened with them.
…ent's FlureeBuilder and the Fluree constructors defaulted to allowing every host identity; an embedder that never called with_host_identity_policy ignored the operator's FLUREE_GRAPH_SOURCE_HOST_IDENTITIES and FLUREE_GRAPH_SOURCE_AMBIENT_BUCKETS. They now start from HostIdentityPolicy::from_env, which is allow-all when neither is set.
bplatz
left a comment
There was a problem hiding this comment.
Approving, with one ask: please fix the cached storage identity (item 1 in the first comment above) before this merges. Everything else in the two comments can land here or as follow-ups.
The identity design holds up well where I looked hardest: the token-destination rule (suffix matching, userinfo, IP literals, https-only, no redirects on the token and catalog clients), the WIF config allowlist, the token cache key binding the secret and the AWS subject, refusals that never echo values, and scheme gating and identity-scoped cache keys on the storage side.
… that resolves its secret The process-wide storage identity cache keyed a built identity on the stored configuration (the secret reference, not the secret) and the identity context, and a hit never asked the secret resolver. Under a resolver with no scope id, a caller who registered a Direct gs:// source naming another caller's secret_ref was served that caller's identity, and the token proof passed because the identity already held the key, though its own resolver would have refused the reference. The identity's configuration is now hydrated through the caller's resolver on every plan, before the cache is consulted, for both storage_auth `google` and `catalog`. The cache key is a digest of the resolved configuration, exactly what the identity is built from, and building refuses an unresolved reference: an entry exists only under the digest of resolved secrets, so a caller is served a cached identity only by presenting what it was built from. A caller whose resolver refuses the reference fails at hydration; one whose resolver maps it to another secret keys another entry; a rotated secret keys a new entry at once. A warm plan still reuses the built identity (no key parse, no new HTTP client) and still proves it with a token from the process-wide token cache. What it adds is the resolver call per plan, the same contract the Delta handle cache has: authorization runs on every use.
… flight holds no one up The Google token cache held its slot's lock across the token exchange and remembered nothing when it failed, so during an STS or metadata server outage every queued caller ran its own exchange in turn, each up to the client's 30 s timeout; inside the refresh margin, a caller whose held token was still valid waited for a failing refresh before reading on with it. Vended storage credentials renewed the same way, and a store's 401 forced a re-vend every time, with no guard like the Google path's 30 s one. The REST catalog client took its process-wide request permit before asking its auth provider for headers, so an issuer outage could hold every catalog slot, those of sources on other credentials included. Both holders now renew through one shared renewal (`renew::Renewing`): - One renewal is in flight at a time. While it runs, a caller holding a still-valid credential reads on with it without waiting; a caller with nothing usable waits for that renewal instead of starting its own. - A failed renewal is remembered for 5 s. Within that window nothing is renewed: a still-valid credential is served, else the failure is returned at once. - A refusal forces a renewal at most once per 30 s, for vended credentials as for Google tokens. A vended credential the store refused is still never served again. A Google token's forced renewal that fails still leaves the held token for the other sources sharing it. The REST client takes its headers before the permit and reuses them across 429/503 retries; a token that expires during those is a 401, renewed as before. The fast path (a fresh held credential) takes a short std mutex instead of an async one; no extra work is added to it.
…grant on it
Google answers USER_PROJECT_DENIED both when a request names no quota
project and when it names one the caller lacks
serviceusage.services.use on. The catalog client reported both as
CatalogQuotaProjectRequired ("set quota_project"), wrong advice in the
second case.
When the request carried x-goog-user-project, the refusal is now the
catalog's access denial, naming that project and the missing permission
in the words the GCS denial hint uses (now one shared text). A request
that named none is still CatalogQuotaProjectRequired.
… it read as A GCS denial names the store's identity (`as Google (<principal>)`) and carries GCS's own message, which names the service account (or a user's email). The query path redacted AWS ARNs from denials but no Google principal, so any querying client was told the identity the server read the table as. The query-facing denial now also replaces the store's label principal (service account, `wif:…`, `adc:…`, `metadata`) and every email address with `<redacted>`, keeping the reason; the full text goes to the server log, as for ARNs. Onboarding and verify keep the full text.
The GCS reader built its HTTP client through object_store's ClientOptions, and object_store sets no redirect policy, so reqwest's default (follow up to ten) applied. reqwest drops Authorization across hosts, but x-goog-user-project would still have gone wherever a response pointed. Each bucket's client is now built by a connector of the reader's own: the same timeouts, user-project header, http-only-for-an-operator's- endpoint rule and disabled decompression object_store applies, with redirects off. A redirected read fails with the redirect's status. The connector uses the reqwest 0.12 object_store is built on, already in the build through it.
…with them loadTable parsed whatever credentials a catalog returned, including the GCS fields this PR added, whether or not the source reads with vended credentials. A catalog returning a gcs.oauth2.token without an expiry, or a malformed gcs.user-project, failed loadTable for ambient, catalog and google sources that would never use it. And for a gs:// table whose catalog vends both, the GCS token now won over the S3-interop keys, switching existing records to another store. - The REST client reads credentials only from a load that asked for them, and every loadTable asks exactly when the source's storage identity is `vended`. - When a catalog vends both, the S3 keys win whatever the location, as they did before this PR; the GCS token is read only when no S3 keys were vended. - `IoConfig::effective_storage_auth` now takes the catalog and is the one rule: an absent storage_auth means `vended` on a REST catalog with vended_credentials, `ambient` everywhere else. plan_storage and the loadTable request both follow it. Before, the public method returned `vended` for Glue, S3 Tables and Direct with the default vended_credentials: true, where plan_storage read them as ambient.
…d once per backoff The Google token cache now backs off for 5 s after a failed exchange, so a second plan inside that window is refused with the cached failure instead of asking the AWS subject again. The warm-plan test asked for one exchange per plan; it now asks that each plan is refused (the proof is never skipped for a cached identity) with one exchange in the window.
…fields A remote `fluree sql map` sent its auth only as the structured `auth`. A server older than that field does not refuse a field it does not know: it registered the source with no auth and said nothing. A bearer token or OAuth2 client credentials (literal or `_env`) now go as the flat fields, which every server version reads. Only a Google identity, which has no flat field, goes as the structured `auth`. The server converts the flat fields with the codec the CLI checks them with, so the stored record is the same either way: the test builds the body for each auth kind and parses it as the server does.
`--auth-google-wif-config` / `--storage-google-wif-config` accepted any JSON object, and a remote map sends the file as read without the static check a registration runs. A service-account key passed there by mistake travelled to the server before it was refused. The CLI now checks the file as a registration would before building any request: its `type` must be `external_account` (a service-account key is named as such, pointing to the `-service-account-env` flag), and the configuration must pass the same static validation the server applies. No refusal repeats the file's contents.
The typed redactor replaced the name-based pass rather than adding to it: a config its type could read was returned as the type masked it. A value the type holds as plain text under a secret-sounding key, such as a SQL session property named `x_token` or `password`, was masked before by the `*_token` / `*_secret` / `*_password` rule and was shown verbatim. A secret field a config type gains outside its auth would not have been masked either. The name rule now runs after the typed pass, always. A config neither pass changes is still returned byte-identical.
`CatalogConfig` was read through an untagged helper that fell back to
the legacy REST form whenever the tagged reading failed. So
`{"type": "direct", "uri": "https://c"}` (a Direct catalog missing its
table location) or a misspelled type read as a REST catalog, and since
`type` is in the canonical output the strict input check did not refuse
it. Any refusal inside a structured `catalog` also said only "data did
not match any variant of untagged enum CatalogConfigHelper", without a
path.
The catalog is now read key by key: each key as its own type, the
variant decided by `type` alone, its absence meaning the legacy REST
form. A stated type that does not parse as that variant is refused, and
the refusal names where: `catalog.type: unknown variant, expected one
of ...`, `catalog: missing field table_location`,
`catalog.auth.type: ...`, `catalog.warehouse: invalid type ...`.
Untyped legacy records read as before, keys no variant knows are still
ignored on read, and the written form is unchanged.
`fluree.Google("wif.json")` was refused, with a message telling the
caller to pass the path it had just passed: only an `os.PathLike` was
read as a file. A missing file raised a bare FileNotFoundError.
A string that is neither "metadata" nor "application_default" is now
the path of a WIF configuration file, read like a Path, unless it is
JSON text (a key given literally, refused as before). A file that cannot
be read, or a string naming no file, is an InvalidRequestError that says
so. A refusal of a string never repeats it, since it may be a key.
9d9aca6a3 said the flat fields are read by every server version. An older server reads the literal ones only: the `_env` forms are as new as the structured `auth`, and it drops them as it drops a Google identity. The doc comment now says so.
The read-only routes refused a field only a map route uses: the Iceberg browse, preview, verify, generate and validate routes refused `name`, `r2rml`, `branch`, `model`, `delete_*` and the rest of `iceberg/map`'s own fields, and Delta browse and generate refused the S3 and Azure options. Earlier releases ignored them, so a client sending one body to browse, preview and map now got 400s. Each read-only route now drops the fields its kind's map route takes beside the connection (unless it takes the field itself), and the Delta routes also drop what they cannot use: the Azure principal on every read-only route (Unity issues a Unity table's credentials; this replaces preview and verify's refusal of it), and on browse and generate, which read no table, the S3 options and `io`. What is dropped is ignored, not checked. A field no route of the kind knows is still refused.
The flat Unity fields default an OAuth2 service principal's scope to `all-apis` (and its token URL to the workspace's own); a structured `unity.auth` was stored exactly as given, so OAuth2 client credentials without a `scope` were stored, and requested tokens, with none. The same source registered two ways stored two records. A structured `unity.auth` now gets the same default scope (its `token_url` cannot be omitted in that form). The flat-vs-structured test family pins that both forms store the same record, with the scope left out and with one given.
…or changes - api/errors.md: the five new codes, each under its status: err:auth/GoogleCredentialsInvalid and err:storage/SchemeNotServed (400), err:auth/GoogleTokenExchange (401, 403 or 502), err:auth/HostIdentityRefused and err:catalog/QuotaProjectRequired (403). - operations/configuration.md: FLUREE_GRAPH_SOURCE_HOST_IDENTITIES lists `azure` (an operator copying the old list turned off ambient-Azure Delta reads) and says `aws` also gates the Glue and S3 Tables catalog calls. FLUREE_GRAPH_SOURCE_AMBIENT_BUCKETS says an ambient source may not name an s3_endpoint while it is set, and that it governs storage reads only. - api/endpoints.md: the delta/map structured-form paragraph sat inside the field table, so the rows after it lost their header; it follows the table now. A stated catalog type is read as that type only, a structured Unity OAuth2 auth defaults its scope as the flat form does, and the read-only Iceberg and Delta routes ignore what only map uses. - graph-sources/iceberg.md: GCS is read through the native reader for every Google identity (the source's own, the catalog's, a vended GCS token), through the S3 interop endpoint with HMAC keys otherwise. Vended credentials are renewed from the catalog, not "refreshed by the SDK". Test history leaves the feature guide. - graph-sources/sql.md, cli/sql.md: a host identity's token goes only to Google's APIs and FLUREE_GOOGLE_TOKEN_HOSTS, so against an ordinary Trino endpoint only a service-account key works unless the operator lists the host. The CLI's remote body, and what an older server reads of it. - reference/compatibility.md: the requests graph-source routes now refuse (unknown fields, auth two ways or partly, unlisted `_env` names, a mistyped catalog), what registration now refuses, and the identity failures that changed code.
…zure stays refused on preview 5b7880838 let a read-only route ignore `map`'s own fields, but a key of another read-only route (preview's `table` or `namespace`, browse's `depth`, generate's `base_namespace`) was still refused, so one payload sent to browse, preview and map still drew 400s. Each route now ignores every field a route of its kind takes beside the connection (ROUTE_FIELDS, one list for Iceberg and one for Delta), map and validate included. A route reads its own fields first, so a shared name keeps its own meaning there. A key no route of the kind knows is still refused on every route. 5b7880838 also made Delta preview and verify ignore an Azure principal. That is a storage credential: ignoring it would let a caller believe the table was read as that principal, when Unity issues the credentials. The 400 naming `azure` is back on those two routes. Browse and generate read only Unity's record of a table, never its files, and keep ignoring the storage options, Azure included.
… server refuses iceberg map - api/endpoints.md: each Iceberg and Delta route ignores the fields only another route of its kind takes, listed by route. Delta browse and generate read no data files and ignore the storage options; preview and verify refuse an Azure principal. - reference/compatibility.md: the same in the behavior change, and a `fluree iceberg map --remote` from this release is refused with 400 by an earlier server, which does not read the structured `catalog` / `io`.
|
Thanks @bplatz, this was a really careful pass. Everything in both comments is folded in here except one smaller item that turned out not to have the shape described (below), 20 commits on top of 1. The cached Google storage identity (your pre-merge ask) — 2. Backoff — 3. A new CLI against an older server — 4. The redactor — 5. 6. Docs — The smaller items:
Every new test fails with its fix reverted. And per your note on #2198, the body now has a checklist line for re-keying its count cache by storage scope when it meets this. |
One conflict, docs/reference/compatibility.md: both sides added subsections to the flat Behavior changes list (this branch's strict graph-source requests, main's v4.2.5 entries). Both are kept, this branch's first.
…s-from-manifests Brings in per-source storage identities (#2196) and the graph-source crawl fixes (#2199). The manifest-list totals cache is keyed by the manifest-list location qualified by the `StorageScope` of the storage plan that read it, as `table_metadata` and `scan_files` already are, so a total read under one identity is never served to another. - cache.rs: the totals accessors take the scope and key by `scope.qualify(location)`. - r2rml.rs: the three totals helpers take the scope; the /info read decides its storage with `catalog_read_plan` and builds it with `catalog_read_storage(&plan, &grant)`, the query path's decision. - iceberg_catalog.rs: `preview_iceberg_table_in` takes the identity context and the cache; `preview_storage_plan` is split out of `build_preview_storage` so the Schema-tier preview keys its totals by the plan's scope before building anything. The Stats-tier callers in iceberg_generate.rs and iceberg_validate.rs pass no cache. - ledger_info.rs: the /info count takes a plan closure. The deadline bounds the plan as well as the read, because planning a Google identity resolves its secret and proves the identity, either of which can be a remote call. The plan is polled once before the deadline is consulted, so a plan that is ready at once (ambient, vended, or a warm Google identity behind a resolver that answers at once) still serves a warm count past the deadline. - it_iceberg_local_fs.rs: both sides' tests are kept.
…out-mapping Brings in per-source storage identities and the one graph-source input codec (#2196), and the graph-source crawl fixes (#2199). Every resolution keeps both PRs' behaviour; where #2196 still offered a way to register an Iceberg source without a mapping, this branch's rule (a source needs a mapping) wins: - `create_iceberg_graph_source` and `test_iceberg_connection` stay removed. #2196's Direct storage-policy check at registration (`refuse_direct_storage_the_policy_refuses`) is kept, on the one remaining surface. Its two tests register through `create_r2rml_graph_source` with a mapping. - `IcebergCreateConfig::from_connection_for` and `iceberg_create_from_json` take no `has_mapping` flag, and `CatalogModeError::MissingTable` stays removed: a catalog mode's tables come from its mapping. - `POST /iceberg/map` keeps `required_mapping` (refused in words before the codec runs) and the response's `connection_check`. The codec's `ROUTE_FIELDS` list request fields; `connection_check` is a response field, and this branch adds no request field. - The CLI keeps main's codec-built connection and this branch's required `--r2rml` and `Connection:` line; its tests name a mapping. - Python keeps main's builder-based connection and this branch's per-outcome warning, with the released "could not reach the catalog" wording for a catalog that did not answer. - error.rs, errors.md: both PRs' error codes and statuses. - The docs keep #2196's connection sections and this branch's mapping rule and `connection_check`.
Brings #2247, #2232, #2246, #2248, #2245, #2230, #2205, #2231, #2255, #2219, #2209, #2207, #2190, #2216, #2186, #2215, #2213, #2184, #2210, #2206, #2198, #2187, #2183, #2200, #2193, #2199, #2196 and #2145 into next. Resolutions: - Novelty: main's fact-state trim (a cutoff plus a bounded sweep) and the dictionary's coverage watermark sit on next's graph slots and per-graph OrdMaps. A commit's reification links count toward coverage. Planner stats from segment sums decline under annotations, whose link deltas only the walk counts, and otherwise carry the indexed link counts. - Stats-view identity: the index root's id reaches the snapshot through next's root decoder (`decode` takes the id, as `take_snapshot_metadata` does). `LedgerState::load_record` has a decoding-root form beside `load_decoding_root`. - Transact: #2184's parallel-relationship check runs in next's link cascade, counting the `rdf:reifies` links on the retracted edge that the transaction does not retract itself. Main's bundle `edge_reifiers` is dropped, and `subjects_with_prior_rows` and `enforce_single_target_reifiers` stay deleted. The upsert pre-check takes main's dictionary probe and bounded seek. - Query: geo search resolves the graph's POST tree once at open (pooled graphs keep their filter), an empty manifest when there is none. `branch_or_none` reads the dedicated branch, and the batched joins keep next's pooled lanes. The stats-view key hashes the root id. - Indexer: `apply_dict_novelty` and `compact_forward_streams` take the cycle's compaction budget, so the term dictionary keeps its reserved share. `Prefetched` holds `ContentBytes`. `relocalize_sorted_commit` rewrites next's 20-byte types records. - Disk cache: main's in-flight write registration, with an empty entry still read as crash debris that a write replaces. The process-wide eviction walk stays removed. - Graph import (#2232): fenced CAS and publishes, the seed carries the record's namespace and fence, 32-bit graph ids and next's loaders. An import into a graph of an existing ledger refuses triple terms and edge annotations: the splice merges no triple-term dictionary yet. - Iceberg: `create_iceberg_graph_source` goes with main (a source needs a mapping); the R2RML path keeps next's `model_instance`. - CLI: main's shared import flags without the leaflet flags; `graph import` routes through next's process-wide server routing, and `upload_source_import` serves next's `Destination`. Doc sources read a ledger through the command's open instance. - Tests: sibling ledger ids become distinct names, `genesis_ledger` is awaited, Cypher state dumps include each relationship's `rdf:reifies` link, and the graph-import arena test checks the refusal instead.
Fixes #2194
Fixes #2195
Follow-up: #2182, #1914, #2189, #2192
This lets a graph source read BigQuery-managed Iceberg tables through Google's BigLake Iceberg REST catalog, from GCP or off it, without HMAC keys, and it reworks how connection, auth and storage config gets into db so that every surface says the same thing. Fair warning up front: it's a big one, with a breaking-change list to match, and Claude Code did a lot of the legwork here, including the design review, the wiremock suites, the mutation checks and the live runs against BigLake and GCS. The reviewer map below is the order I'd read it in.
What and why
Three things, and they turned out to want each other:
A Google identity behind catalog auth.
{"type": "google", "credentials": …, "quota_project": "…", "scopes": "…"}. The credential comes from one of four sources:external_account: Workload Identity Federation from AWS, keyless, with nothing secret stored; this is the recommended one;service_account: a key held in an env var or secret reference, never a stored literal;metadata: today'sgoogle_metadata, which keeps reading and round-tripping;application_default: host ADC, for development.CachedTokenand hardened HTTP client, with no new dependencies, rather than adoptinggoogle-cloud-auth. A credential config can name arbitrary token URLs, files, URLs and executables, and accepting one from a source's config means validating it.quota_projectgoes out asx-goog-user-project. BigLake refuses every request without one, for every identity, and that now comes back aserr:catalog/QuotaProjectRequiredsaying to set it.AuthConfig, a Google identity authenticates SQL endpoints too.A per-source storage identity.
io.storage_authisvended,ambient,catalogorgoogle. Absent, it means whatvended_credentialsalways meant, so stored records are untouched.catalogfor abq://warehouse andvendedforbl://; HTTP stores exactly what it's sent.err:storage/SchemeNotServed.catalogis what makes BigLake federation work: it never vends, and Google's own model is that the catalog caller's identity reads the bucket.object_store'sGoogleCloudStorage(already linked into every shipped binary throughdelta_kernel), with read-only storage scopes.Fluree::graph_source_storage, which returns the decision it made. Every location-keyed cache is scoped by the identity that read it.Every host-derived identity under one policy.
FLUREE_GRAPH_SOURCE_HOST_IDENTITIESandFLUREE_GRAPH_SOURCE_AMBIENT_BUCKETS, orwith_host_identity_policyper instance. It defaults to everything allowed, so a single-tenant install behaves as before.with_aws_subject_credentials) for WIF, which the policy doesn't gate.*.googleapis.com, plus any host the operator lists inFLUREE_GOOGLE_TOKEN_HOSTS.One codec for every surface.
auth_*fields with hand-written code, and those copies had drifted. Google metadata auth worked on/iceberg/maponly, a partial OAuth2 set was silently ignored for Iceberg and SQL but refused for Delta, and precedence between auth modes differed per kind.fluree-db-api/src/graph_source/surface.rsis now the one path. Structured input is exactly the stored JSON (catalog/iofor Iceberg,authfor SQL,unity/iofor Delta), on every route. The legacy flat fields still work through one converter per kind, and catalog auth through one converter for all three kinds.err:api/InvalidGraphSourceConfig, naming the field. EveryConfigValueon the wire goes through the same rules.surface/refusal.rs, in65f8c305c). serde's own message quotes the value it was given, which can be a credential pasted into the wrong field, so it never reaches the 400. The codec's own refusals stop repeating values too: an env var the operator doesn't list, an unknown storage identity, an unknown catalog mode. Acceptance is unchanged; serde_json still decides what parses.How to review it
Roughly in this order:
fluree-db-iceberg/src/auth/google/:mod.rsholds the identity, the token destination rule andgrantable_scopes; thenexternal_account.rs,service_account.rs,adc.rs,metadata.rs,cache.rs,credentials.rs,aws_subject.rsandtests.rs.fluree-db-iceberg/src/auth/mod.rs:request_headers(url),IdentityContext,AuthConfig::Google.fluree-db-iceberg/src/host_identity.rs.catalog/rest.rs,fluree-db-sql/src/trino.rs,fluree-db-delta/src/unity.rs.fluree-db-iceberg/src/io/gcs.rs(the reader);io/storage.rs,io/location.rs,io/scope.rs(scheme binding andStorageScope);credential/vended.rs,credential/renewal.rs;io/send_parquet.rs(the data-file cache key and its single-flight fill).fluree-db-api/src/graph_source/storage.rs(plan_storageand the one constructor), then its call sites inr2rml.rs,cache.rsanddisk_catalog_cache.rs.fluree-db-delta/src/store.rs,table.rs.fluree-db-api/src/graph_source/surface.rsand itstests.rs;graph_source/config.rs;ledger_info.rs.fluree-db-server/src/routes/{iceberg,sql,delta,iceberg_ssrf}.rs.fluree-db-cli/src/commands/source_auth.rs(the three flag groups) andcommands/{iceberg,sql,delta}.rs.fluree-db-python/src/graph_source.rs,python/fluree/_sources.py.fluree-vocab/src/errors.rs.fluree-db-api/src/error.rs.fluree-db-iceberg/src/error.rs,fluree-db-query/src/error.rs,fluree-db-sql/src/error.rs,fluree-db-delta/src/error.rs.api/endpoints.md(a new "Iceberg connection" section),api/errors.md.graph-sources/iceberg.md(a new "Google BigLake" section with the minimum roles),graph-sources/sql.md,graph-sources/delta.md.operations/configuration.md(the policy and override env vars).cli/iceberg.md,cli/sql.md,cli/delta.md,cli/server-integration.md.docs/types.md.Breaking changes
Rust API
fluree_db_api::{browse_iceberg_catalog, preview_iceberg_table, verify_storage_access, sample_iceberg_rows, sample_column_values}. Use theFlureemethods; verify isFluree::verify_iceberg_storage_access. A catalog read always runs under an instance's identity context (its policy, AWS subject and secret resolver), and the free functions had none.generate_r2rmlandvalidate_r2rmlnow preview under the instance's context as well.S3IcebergStorage::from_default_chainis#[doc(hidden)]and#[deprecated], and refusesgs://without a GCS interop endpoint. Storage is decided and built byFluree::graph_source_storage(&config, &CatalogGrant::direct()), which returnsResolvedStorage { backend, decision, scope }with a#[non_exhaustive]StorageDecision.DeltaTable::open(name, location, io, identity: &IdentityContext), because a path source's ambient read is a host identity the policy governs. Embedders can callFluree::open_delta_table(name, location, io)instead.CatalogAuth/SendCatalogAuth:authorization_header() -> Result<Option<String>>is replaced byrequest_headers(&self, url: &str) -> Result<HeaderMap>. It's one method that returns every header (Google'sx-goog-user-projectincluded), and it takes the request URL so the provider decides where its credential may go.GoogleMetadataAuthandGoogleMetadataConfigare removed;GoogleCatalogAuthover aGoogleIdentityserves both Google auth variants.AuthConfiggainsGoogle.IoConfiggainsstorage_auth, defaulted and skipped when absent; no existing field is renamed or removed.FlureeBuilder::{file, memory, s3, from_json_ld}andFluree::{new, from_backend, with_indexing_mode}now default toHostIdentityPolicy::from_env(), so an instance with no policy of its own takes the environment's.HostIdentityPolicyhas a new pub fieldambient_azure, andHostIdentityKinda newAzure. An explicitFLUREE_GRAPH_SOURCE_HOST_IDENTITIESlist must nameazureto keep ambient-Azure Delta reads.IcebergError::{GoogleTokenExchange, GoogleCredentialsInvalid, HostIdentityRefused, CatalogQuotaProjectRequired, SchemeNotServed, AmbientBucketRefused, AmbientEndpointRefused, LocalLocationFromCatalog, GoogleTokenHostRefused};QueryError::{StorageSchemeNotServed, CatalogQuotaProjectRequired, GoogleTokenExchange, GoogleCredentialsInvalid, HostIdentityRefused, GoogleTokenHostRefused};SqlError::IdentityandDeltaError::Identity;ApiError::GraphSourceInput.IcebergError::StorageAccessDeniedandQueryError::StorageAccessDeniedgainscheme. A non-S3 denial arrives asApiError::Query(QueryError::StorageAccessDenied), still 403err:storage/AccessDenied.err:auth/GoogleTokenExchange,err:auth/GoogleCredentialsInvalid,err:auth/HostIdentityRefused,err:catalog/QuotaProjectRequired,err:storage/SchemeNotServed,err:api/InvalidGraphSourceConfig.VendedCredentialsis nowS3(S3Credentials) | Gcs(GcsCredentials), andfrom_vended_credentialstakes&S3Credentials. A vended GCS token with no expiry is refused.R2rmlCache::{get,put}_metadataandSendParquetReader::with_cachestake a&StorageScope.SecretResolver::scope_id()is a new provided method, defaulting toNone. A resolver that maps one reference name to different secrets per caller must return a scope id, so per-identity caches can tell them apart.StorageAccessReport.credential_sourcegainscatalog,googleandlocal.IcebergConnectionConfig,IcebergCreateConfigandR2rmlCreateConfiggainwith_auth/with_storage_auth.with_storage_authalso setsvended_credentialsto agree.with_warehouseon Glue orwith_oauth2_scopewithout OAuth2 auth, is now refused atvalidate()(typed, naming the actual mode) rather than logged and ignored.IcebergConnectionConfighas a private field, so it can't be built with a struct literal outside the crate.Behavior
Registration runs the engine's own validation in every mode, the same
IcebergGsConfig::validatea query runs on the stored config. That covers:catalogneeds a Google catalog identity, andvendedneeds a REST catalog;namespace/table.Separately, a Direct or Delta path source whose storage the policy refuses fails registration with the 403 a query would give. Every catalog read (browse, preview, verify, generate, validate) validates its connection first.
A source's storage identity is decided by its config, deliberately. An
ambientsource, explicit or fromvended_credentials: false, reads with the ambient identity even when the catalog happens to vend credentials it didn't ask for. Before, those unrequested credentials were used.Catalog-only clients: the Glue and S3 Tables catalog clients are the
awshost identity, governed by the policy like the ambient reads.With
FLUREE_GRAPH_SOURCE_AMBIENT_BUCKETSset, an ambient source may not also name ans3_endpoint. The allowlist names buckets on AWS's own endpoint, and a bucket name means something else on another one.Local files are read only by a Direct source under the operator's local roots. A catalog that places a table on local disk is refused with
err:storage/SchemeNotServed.Host tokens: a host identity's Google token goes only to
*.googleapis.comand the hosts listed inFLUREE_GOOGLE_TOKEN_HOSTS. A deployment that points the metadata server, ADC or host-signed WIF at a private, non-googleapis endpoint needs to list that host.Quota projects:
storage_auth: catalog, GCS gets nox-goog-user-project.storage_auth: google's ownquota_project, or thegcs.user-projecta catalog vends.quota_project_idno longer bills storage reads. Anyone relying on that should setstorage_auth.quota_project.User ADC (
authorized_user) tokens are minted forcloud-platform, for the catalog and storage alike. A refresh grant can only ask for scopes the user consented to, and gcloud's login consents tocloud-platform. Service-account, WIF and metadata tokens are still minted read-only for storage.Cache keys: vended sources, ambient sources with an endpoint override, and instances with a non-default identity context re-key their catalog and data-file caches once on upgrade. The default ambient, no-endpoint configuration keeps its keys.
HTTP
sql/mapand every Delta route now answer 400err:api/InvalidGraphSourceConfig, naming the field, for:oauth2_*field without both the token URL and the secret used to store no auth at all.FLUREE_GRAPH_SOURCE_SECRET_ENV_VARSis refused, on every route and for every value,azure_client_secret_envincluded;secret_refis accepted only when the instance has a resolver;default_val,java_propertyand ametadata_urlare refused.auth_google_metadatanow reaches every read-only Iceberg route.sql/mapgainsauth_bearer_env,oauth2_client_secret_envand a structuredauth; the Delta routes gainoauth2_audienceand a structuredunity/io.delta/catalog/previewandverifyrefuse an Azure principal, since Unity issues the table's credentials.storage_author the quota project: an omitted one keeps today's behavior.CLI
iceberg mapandsql map:--auth-google-metadata,--auth-google-adc;--auth-google-service-account-env VAR;--auth-google-wif-config FILE, which is read and stored inline (it's not a secret);--auth-google-quota-project,--auth-google-scopes.iceberg mapalso takes--storage-identity vended|ambient|catalog|googleand--storage-google-*.--no-vended-credentialsconflicts with--storage-identity.sql mapgains--auth-bearer-envand--oauth2-client-secret-env.--oauth2-audience. Their old claprequires = "unity_uri"is checked by the converter instead.bq://warehouse reads withcatalogand abl://one withvended;bq://warehouse without a Google catalog identity is refused, naming the flags to use;iceberg map/sql mapsend the structured connection their local form would store, so remote and local register the same record.distbuilds, includeiceberg. Only a custom--no-default-featuresbuild withouticebergcan no longer sendiceberg map/sql mapto a remote server.deltafeature can still drive a server.Python
fluree.Google(credentials="metadata" | "application_default" | EnvVar | dict | path, quota_project=None, scopes=None)is new. A literal key string is refused.Authnow includesGoogle.map_iceberg(storage=…)is new, along with theStorageIdentitytype. It takes the samebq:///bl://defaults as the CLI, and a Google identity takes the warehouse's quota project.RestCatalogMode.auth/iodirectly. The REST-only refusals come at registration, with the same messages.Tests and validation
On the final tree, with the iceberg, native, sql and delta features unless noted. All pass.
Iceberg crate
--features awsit_scan/it_value_codecSQL and Delta crates
no_log_cache/ pruningAPI crate
--all-featuresgrp_graphsourceit_graph_source_r2rmlit_iceberg_local_fs/it_iceberg_policy/it_iceberg_warehouse_rootit_sql_graph_source/it_sql_pushdown_laneit_delta_local_fs/it_delta_differentialit_host_identity_env_default(new; re-execs itself so the env policy stays in its own process)it_google_storage_billing(new)it_iceberg_direct(aws-testcontainers, LocalStack)Server, CLI and Python
--all-featuresgrp_http138,grp_policy95,grp_proxy53,grp_query186,grp_raft20,grp_search20,grp_bolt28 (counted in the round before the live fixes, which reran them green)graph_source_flags(new) 3, and the other targets-n -WcleanGates, all clean:
cargo fmt --all --check;cargo clippy --workspace --all-features --all-targets -- -D warnings;cargo check --workspace --all-targets;RUSTDOCFLAGS=-D warningsdocs for the iceberg and delta crates.One flake to be aware of:
grp_http::encryption_rotation_http::rotation_runs_and_verifies_over_httpfails in some whole-binary runs. It polls a key rotation for 10 s, passes alone, and nothing here touches encryption.No network in CI. Every Google and GCS path runs against wiremock:
GetCallerIdentitywithx-goog-cloud-target-resourcesigned, and impersonation'sexpireTimeis parsed. Two embedder subjects with different principals make two exchanges for one config, never a shared token.it_google_storage_billingdrives the metadata server, a BigLake-style catalog and GCS throughverify_iceberg_storage_access, and pins which project each request bills.AuthConfig×GoogleCredentials×ConfigValueform.Mutation checks. 98 were recorded across the storage, surface, review and live-fix rounds (29 + 10 + 18 + 18 + 11 + 12), with Phase 1 running its own. Each one broke the code on a committed tree, watched its test fail, and restored it. A few earned their keep by catching tests that didn't yet test anything:
cargo fmt, which was rerun rather than counted.Live validation against real BigLake and GCS, in a Google Cloud test project (us-central1), in two rounds:
bq://projects/<P>/locations/us-central1);NUMERICtable and a 2,000,000-row (~24.5 MB) one;roles/biglake.viewerandroles/bigquery.metadataVieweron the project androles/storage.objectVieweron the bucket;/v1/config, which now readserr:catalog/QuotaProjectRequired;serviceusagegrant they had no business needing. It now bills the catalog only;400 invalid_scopeon the storage token. A user's refresh grant can only ask for scopes the user consented to, so a user's token is now minted forcloud-platform;gs://source couldn't register, even with an identity that readsgs://;storage_auth: catalog, with noserviceusageroleNUMERICasdecimal(38,9)storage_auth: googlewith aquota_project)UserProjectAccessDeniedfor lackingserviceusage.services.use, in one linebq://warehousestorage_auth: cataloggoogle-wifThe control is what makes the first row mean something. The
serviceusagegrant the first round needed had been removed, and the control shows the removal took effect: GCS checks that permission and refused, while BigLake, billed to that same project, answered/v1/configandloadTable. WIF's warm runs are still new processes, so each one pays the STS exchange and the impersonation again; a long-running server caches the token for about an hour.Decimal filters. On this branch alone, a
FILTER(?v >= 0.05)on theNUMERICcolumn crashes the Parquet read (scale 2 is greater than precision 1), for every decimal variant. That's expected: it's the bug #2186 fixes, and this branch doesn't carry it. On a build combining this branch with #2186, all nine decimalFILTERvariants (>=,>,=and<on0.05, a typedxsd:decimalliteral, bounds a hair past a stored value, and two on a secondNUMERICcolumn) returned exactly the expected rows, 2.81 s cold and 2.48 / 2.56 s warm. AnyFILTERon that table costs about 1.4 s more per one-shot process than the same query without one, on both builds and on alongcolumn too, so it isn't from either change; I'd like to profile it separately. Outside the filters, the combined build matches this branch (warm, 0.98 vs 0.97 s).Roles. The three roles above were enough for the catalog and storage both, with the quota project being the project that holds the tables, which is the default from the warehouse. Billing a different project wasn't tested. Google's rule for
x-goog-user-projectis that the identity then also needsserviceusage.services.useon that project (roles/serviceusage.serviceUsageConsumer), and the docs say it that way: the first case validated, the second Google's rule.2M-row reads (first round) through the GCS-native reader with the catalog's identity:
COUNTGROUP BY(100 buckets)ORDER BY+LIMITAgainst the S3-interop HMAC path (first round), each run a fresh process with a fresh disk cache:
COUNTGROUP BYSo the data path seems to be at parity. The fixed ~150–200 ms gap is one extra Google token exchange per process, because storage tokens carry their own read-only scope, and a long-running server caches it for about an hour.
Merge checklist
/infocount cache by(StorageScope, location)as it meets this PR, with its two-scopes test (virtual_count_cached_under_one_scope_is_not_served_to_another). The compiler won't catch a merge that keeps the old key.Review round (2026-10-30)
bplatz's two comments are folded in across 20 commits on
65f8c305c: the cached storage identity is resolved through the caller's resolver before every lookup (ccf1348f8); credential renewals back off and never hold up a caller with a still-valid credential (7f2857a13); remotesql mapsends flat fields an older server reads (41f3f259f); the name-based redaction runs after the typed one (6f8e7c01d); a sent quota project's denial names it (0847dc198); GCS reads follow no redirects (5e44840e4); vended credentials are read only when the source reads with them (e7f1455e2); a stated catalogtypeselects its variant (5ad1f6d2f); every graph-source route ignores its sibling routes' fields while unknown keys are still refused (5737923f4,885e9c2cd); plus the CLI, Python and Unity items and the docs, including the stricter behavior listed incompatibility.md.Deferred
GoogleIdentitythroughobject_store's GCS builder.graph-sources/iceberg.md's Type Mapping table now says what happens today (an un-annotatedrr:columnis anxsd:stringliteral), and it's written so that change only has to edit the table.Happy to talk through any of this, especially the breaking changes. I think every one of them follows from the identity being decided in one place, but I may have drawn a line or two in the wrong spot.