Repository navigation
Description
Summary
The Iceberg REST-catalog OAuth2 client-credentials auth supports a scope at the
engine level (OAuth2Config.scope, form-encoded into the token request), but
scope is not exposed through the public config surface — the builders, the
CLI, or the HTTP API all force it to None. As a result, connecting to any
Iceberg REST catalog that requires a token-exchange scope is impossible via the
supported config. The concrete blocked case is Snowflake Horizon Catalog
(Snowflake's built-in Apache-Polaris Iceberg REST endpoint), which requires
scope=session:role:<ROLE> on the /v1/oauth/tokens client-credentials exchange.
This blocks fluree/db-managed Iceberg connections to Snowflake-managed Iceberg
tables (a pattern we want to support / smoke-test).
Why it matters
Snowflake Horizon (and Polaris generally) gate the catalog session role through the
OAuth scope. Without passing scope, the token exchange either fails or yields a
token without the intended role, so the catalog returns no tables. The engine
already knows how to send scope; only the user-facing plumbing is missing.
Evidence (verified against a live Snowflake Horizon account)
Token exchange at https://<org>-<account>.snowflakecomputing.com/polaris/api/catalog/v1/oauth/tokens,
grant_type=client_credentials, client_secret=<PAT>:
| Request | Result |
|---|---|
client_secret=<PAT> + scope=session:role:ICEBERG_READER, no client_id |
200, access_token |
client_id=<non-empty> + client_secret=<PAT> + same scope |
400 invalid_scope |
client_id="" (empty) + client_secret=<PAT> + same scope |
200, access_token |
So: (a) scope=session:role:<ROLE> is required; (b) client_id must be
empty — a non-empty client_id makes Snowflake interpret the request as the
Open-Catalog principal flow (which expects PRINCIPAL_ROLE: scope) and rejects
the session:role: scope.
Separately verified: with a correctly-scoped token, the REST catalog lists all
tables and an external engine (pyiceberg) reads data via vended credentials
(X-Iceberg-Access-Delegation: vended-credentials) — i.e. everything downstream of
the token exchange already works in fluree-db-iceberg.
Code references (HEAD d7f85144f)
fluree-db-iceberg/src/auth/oauth2.rs:17—OAuth2Config.scope: Option<String>exists.fluree-db-iceberg/src/auth/oauth2.rs:82-90—scopeis form-encoded whenSome;client_idis sent unconditionally.fluree-db-api/src/graph_source/config.rs:503-520(IcebergCreateConfig::with_auth_oauth2) and:781(R2rmlCreateConfig::with_auth_oauth2) — both hardcodescope: None, audience: None.- CLI: no
--oauth2-scopeflag; HTTPiceberg/mapbody has no scope field.
Proposed change
- Builders: let
with_auth_oauth2acceptscope(andaudience) — e.g. add a
with_auth_oauth2_scoped(token_url, client_id, client_secret, scope, audience)
or optional setters — threading intoAuthConfig::OAuth2ClientCredentials. - CLI: add
--oauth2-scope(and--oauth2-audience) tofluree iceberg map. - HTTP API: add
oauth2_scope/oauth2_audienceto theiceberg/maprequest. - Empty
client_id: it already works (it's aString), but document that
Snowflake Horizon requiresclient_id="". Optional nicety: omitclient_id
from the form when empty. - Docs: add a "Snowflake Horizon" section to
docs/graph-sources/iceberg.md
anddocs/cli/iceberg.mdwith the exact config (token_url=.../v1/oauth/tokens,
client_id="",scope=session:role:<ROLE>,vended_credentials=true,
warehouse=<database>, UPPERCASE identifiers).
Acceptance criteria
- Can register an R2RML/Iceberg graph source against a scope-gated Iceberg REST
catalog (Snowflake Horizon / Polaris) via both the CLI and the Rust/HTTP API,
passingscope. - An integration test exercises a token endpoint that requires
scope(rejects
the exchange without it). - Docs show the Snowflake Horizon happy path end-to-end.
Workarounds until fixed
- Bearer auth with a pre-exchanged
access_token(--auth-bearer), valid ~1h —
good for a smoke test, not sustained (no auto-refresh). - Hand-write the stored
AuthConfigJSON withscope(the struct supports it even
though the builder doesn't).
Context: this came out of standing up a Snowflake-managed Iceberg dataset (552 M
rows, EXTERNAL_VOLUME = SNOWFLAKE_MANAGED) exposed via Horizon, and verifying
external reads, as the target for a fluree/db → Snowflake Iceberg smoke test.
Activity
feat(iceberg): expose OAuth2 scope/audience for REST catalog auth