Skip to content

feat(iceberg): refreshable Google metadata-server catalog auth - #1567

Closed
christophediprima wants to merge 2 commits into
fluree:mainfrom
christophediprima:feature/iceberg-google-metadata-auth
Closed

christophediprima wants to merge 2 commits into
fluree:mainfrom
christophediprima:feature/iceberg-google-metadata-auth

Conversation

@christophediprima

Copy link
Copy Markdown
Contributor

A static bearer token for a Google Iceberg REST catalog (BigLake) is a short-lived
OAuth access token. It expires after roughly an hour, and BearerTokenAuth has no way to
renew it — so any long-running consumer of that catalog starts returning 401s and stays
broken until someone re-registers the graph source with a fresh token.

This adds AuthConfig::GoogleMetadata / GoogleMetadataAuth, which mints and
auto-refreshes tokens from the GCE/GKE instance metadata server (Workload Identity).

What changes

  • fluree-db-iceberg/src/auth/google_metadata.rs — the provider. Fetches from the
    metadata server with the required Metadata-Flavor: Google header, optional scopes
    (defaults to cloud-platform), and the same cache-plus-refresh behaviour
    OAuth2ClientCredentials already has.
  • fluree-db-iceberg/src/auth/token.rs — the jittered-expiry CachedToken is lifted out
    of oauth2.rs so both providers share one implementation rather than growing a second
    copy. oauth2.rs shrinks by 42 lines as a result; behaviour is unchanged.
  • {Iceberg,R2rml}CreateConfig::with_auth_google_metadata(scopes) and an
    auth_google_metadata field on POST /v1/fluree/iceberg/map.
  • Docs in docs/api/endpoints.md and docs/graph-sources/iceberg.md.

Scope notes

  • Storage credentials are untouched. The GCS reader's HMAC interop keys are static and
    non-expiring; only the catalog leg had the expiry problem.
  • The metadata server is only reachable on GCE/GKE. Local and CI runs keep using a static
    auth_bearer, which is why the tests below drive the provider against a stub server
    rather than the real endpoint.

Tests — two in google_metadata.rs: one asserts the flavor header, the scope string
and that a second call is served from cache rather than refetched; one asserts a metadata
failure surfaces rather than silently yielding no header.

Why it is worth having on its own: this is a correctness fix for anyone pointing
Fluree at BigLake, independent of anything else in #1422 — the expiring-token failure is
real today and there is no workaround short of periodically re-registering the source.

christophediprima and others added 2 commits July 30, 2026 12:16
A static bearer for a Google Iceberg REST catalog (BigLake) is a short-lived
OAuth access token: it expires after ~1h and `BearerTokenAuth` cannot renew it,
so a long-running materialization tracking worker starts returning 401s.

Add `AuthConfig::GoogleMetadata` + `GoogleMetadataAuth`, which mints and
auto-refreshes tokens from the GCE/GKE instance metadata server (Workload
Identity), mirroring the existing `OAuth2ClientCredentials` cache+refresh — the
jittered-expiry `CachedToken` is now shared via `auth::token`. Wire it through
`{Iceberg,R2rml}CreateConfig::with_auth_google_metadata` and the `/iceberg/map`
`auth_google_metadata` field.

The GCS reader's storage HMAC keys are unaffected (static, non-expiring). The
metadata server is only reachable on GCE/GKE; local runs keep using a static
`auth_bearer`.

Extracted from fluree#1422 as part 1 of the split proposed in review. Two adaptations
were needed against current main, neither visible in the diff:

  - `AuthConfig::hydrate` gained a `GoogleMetadata` arm. Spelled out rather than
    folded into a wildcard, so that match keeps failing compilation when a new
    variant appears — `GoogleMetadata` carries no `ConfigValue`, so there is no
    secret reference to resolve.
  - `IcebergCreateConfig` has since been refactored into `connection` +
    `table_identifier` with the auth builders living on `IcebergConnectionConfig`,
    so the `R2rmlCreateConfig` delegator needed a forwarding method alongside the
    existing `with_auth_bearer`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`test_every_auth_config_variant_redacts_on_emit` matches `AuthConfig` with no
wildcard arm on purpose: a new variant is meant to stop the test compiling
until someone has made an explicit decision about whether it carries secret
material. Adding `GoogleMetadata` tripped exactly that guard, so `clippy` and
`test` both failed to build `fluree-db-api`'s lib test target.

The decision it was asking for: GoogleMetadata carries no secret material and
earns no allowlist entry. Both of its fields are plain `String` rather than
`ConfigValue`, so there is no secret-capable field to seed with a sentinel —
the credential is minted per call from the instance metadata server and lives
only in the in-memory `CachedToken`, which is never serialized and whose
hand-written `Debug` prints `***`.

Adds the variant to the fixture so it goes through the redaction assertions
alongside the others, covers it in the canary match, and records the reasoning
where the next person to add a variant will read it.

Only `fmt` passed before this, because it is the one gating job that never
compiles. Verified with the flags CI actually uses — `--all-features` matters
here, since the canary is `#[cfg(feature = "iceberg")]`:

    cargo clippy --all --all-features --all-targets   # exit 0
    cargo test -p fluree-db-iceberg --all-features    # 272 passed
    cargo test -p fluree-db-api --all-features --lib  # 904 passed
christophediprima added a commit to christophediprima/db that referenced this pull request Aug 6, 2026
…tadata arm

Finishes the 24-commit rebase onto `upstream/main` (452 commits of drift). Separate
from the replayed commits because every hunk here is a rebase-resolution artifact,
not a change of intent: nothing in this commit alters behaviour.

THE `parse_manifest_list` CORRECTION.

`send_planner.rs` needed one import added:

    -use crate::manifest::{parse_manifest, parse_manifest_list_with_deletes};
    +use crate::manifest::{parse_manifest, parse_manifest_list, parse_manifest_list_with_deletes};

That single line is the whole of what we spent three review rounds describing as
"fluree#1520 restructured `parse_manifest_list` away, so the rebase is blocked and there is
no mechanical resolution." @aaj3f refuted it in round 3 and was right:
`parse_manifest_list` is on `main` at `manifest/manifest_list.rs:153`, exported from
`manifest/mod.rs:21`, a one-line wrapper over `parse_manifest_list_with_deletes(data,
false)`. Our conflict resolution had taken main's import line while keeping our body,
and we then reported the resulting `cannot find function` as a fact about upstream's
code rather than about our own resolution. One `git show upstream/main:<path>` would
have settled it.

The rest:

- `auth/mod.rs` — `hydrate` gained a `GoogleMetadata` arm. Written OUT rather than
  matched by a wildcard, deliberately: that exhaustiveness is what forced an explicit
  redaction decision for this variant in fluree#1567, and a wildcard here would silently
  accept the next variant too.
- `graph_source/config.rs`, `graph_source/r2rml.rs`, `ledger_info.rs` — three
  functions/initializers left unclosed by a conflict that cut THROUGH a body. Both
  sides ended mid-expression and shared the closing `}`, so taking both halves left
  one closer for two items. Worth naming as a rebase hazard: a union is only safe
  when each side is a whole item.
- `graph_source/r2rml.rs` — upstream's `gs_config_json` auth fixture gained
  `delete: None, order_by: None`. Those fields are ours (`439908642`), so this is our
  breakage of their test, and it surfaced ONLY under `--all-targets`: `cargo check`
  does not build test targets. Same blind spot that took fluree#1567's first CI run down.
- `lib.rs` — export list unioned (`MaterializeResult`, `PersistedMaterializeJob` from
  us; `verify_storage_access`, `StorageAccessReport` from upstream).

NOTE — fluree#1529 HAS MERGED. `fluree-db-api/src/materialize.rs` is now on main (3,174
lines: `materialize_graph`, `WatermarkStamp`, `ImportSink`/`ParsedChunk` ingestion,
parity gate), so the bulk-import engine this PR was asked to converge onto is no
longer a draft. Our replay engine now sits beside it, and there are two watermark
concepts in one codebase. That is a design conversation, not a rebase problem, but it
changes what this branch should become.

PER-COMMIT COMPILABILITY IS NOT RESTORED. The 24 replayed commits are individually
bisect-hostile until these hunks are folded into the commits they belong to. Left as
one commit on purpose: this branch is headed for the four-way re-split, so
`rebase -i` to make a soon-to-be-decomposed history bisectable is poor value. Say the
word and it gets folded.

Verified at this SHA, 0 behind `upstream/main`:
  fluree-db-iceberg  --lib  266 passed
  fluree-db-api      --lib  1014 passed
  fluree-db-server   --lib  167 passed
  grp_graphsource           157 passed
  it_graph_source_r2rml     65 passed
  iceberg_track_durability  4 passed
  cargo fmt --all -- --check          clean
  cargo clippy --all-features --all-targets  clean (3 crates)

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@christophediprima
christophediprima deleted the feature/iceberg-google-metadata-auth branch August 13, 2026 08:15
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