Repository navigation
feat(auth): add mandatory OIDC token exchange - #241
Conversation
There was a problem hiding this comment.
Verdict: 2 Low · 1 Nit
Looks good — clean, well-tested implementation of BYOT token exchange with sound single-flight coalescing and non-breaking fallback. A few low-severity edge notes: follower poll blocks a tokio worker thread, host comparison is port-sensitive, and the server's token_type is ignored when building the header.
Other findings
- ⚪ Nit — The exchange parses and stores
token_type(defaulting toBearer), butget_auth_headerunconditionally formatsformat!("Bearer {token}"), so a non-Bearertoken_typefrom the server would be silently dropped. In practice the exchange always yields a Bearer token for thesqlscope, so this is cosmetic — either honor the returnedtoken_typeor drop the field to avoid implying it's used.
There was a problem hiding this comment.
Verdict: 1 Medium · 1 Low
Solid, well-tested feature — the issuer gating, single-flight coalescing, RAII flag-clear, and non-breaking fallback are all sound, and coverage (unit + wiremock, incl. concurrency) is strong. Two non-blocking notes: the failure-fallback cache entry's effective de-dup window is ~20s not the 60s the comment implies (40s expiry buffer eats into it), and the follower sleep-poll path can park worker threads and doesn't short-circuit once the leader has published. Neither breaks correctness.
There was a problem hiding this comment.
Verdict: 2 Low
Looks good — clean, well-tested implementation of mandatory OIDC token exchange. The single-flight coalescing, expiry/fallback caching math, current-thread-runtime guard, and non-breaking fallback all verify correctly, and all SessionConfig literals are updated. Two minor (Low) notes: a per-request JWT re-parse on the hot path, and a couple of test assertions that could tighten the WIF-vs-BYOT mutual-exclusivity contract.
| pub struct SessionBuilder { | ||
| connection: Option<ConnectionConfig>, | ||
| auth: Option<AuthConfig>, | ||
| identity_federation_client_id: Option<String>, |
There was a problem hiding this comment.
Why not put this in the AuthConfig but as a separate sessionBuilder param?
f57bf34 to
64eeaea
Compare
Exchange foreign-issuer JWTs for workspace tokens while passing through PATs and same-workspace tokens. Cache successful exchanges, coalesce concurrent callers, and fall back to the original token on exchange failures. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Move follower waits off Tokio workers and normalize explicit default ports during issuer comparison. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Match the Python and Go token federation providers by comparing parsed hostnames independently of port. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
d63346f to
1190cd7
Compare
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
Verdict: 2 Low
Looks good — a clean, careful, and unusually well-tested implementation of mandatory OIDC token exchange. Production wiring is sound: the SEA transport retains the strong Arc<DatabricksHttpClient> so the FederationProvider's Weak upgrade succeeds (the cycle-avoidance rationale checks out), the AuthProvider trait has only get_auth_header so wrapping fully delegates, the single-flight leader/follower coalescing re-checks the cache after winning the election (no redundant exchanges), the current-thread runtime is guarded before block_in_place, and non-2xx/parse failures fall back to the original token with wiremock coverage for each. The AuthConfig field additions are threaded consistently through all constructors, bindings, and tests. Only two minor, non-blocking robustness notes are posted inline (coupled-by-comment timeout bounds; an unreachable-by-construction blocking arm).
Implements mandatory OIDC token exchange for foreign-issuer JWTs. PATs and same-workspace OAuth tokens pass through, while exchange failures fall back to the original token.
Adds optional SP-wide WIF configuration to the PAT, OAuth M2M, and OAuth U2M
AuthConfigvariants. Existing constructors retain their current signatures and default the option toNone. Exchange results are cached and concurrent misses are coalesced; binding exposure will follow separately.Testing:
cargo +stable fmt --all,cargo clippy --all-targets -- -D warnings,cargo test, and napi Clippy/tests.