Skip to content

fix: case-insensitive email auth and AI Gateway fallback#114

Closed
dgokeeffe wants to merge 1 commit into
datasciencemonkey:mainfrom
dgokeeffe:fix/gateway-fallback-and-case-insensitive-email
Closed

fix: case-insensitive email auth and AI Gateway fallback#114
dgokeeffe wants to merge 1 commit into
datasciencemonkey:mainfrom
dgokeeffe:fix/gateway-fallback-and-case-insensitive-email

Conversation

@dgokeeffe
Copy link
Copy Markdown
Contributor

Summary

  • Case-insensitive email auth: All email comparisons normalized to .lower() at ingestion points — fixes access denied when SSO X-Forwarded-Email header casing differs from stored owner email (e.g. RC.Guan@ vs rc.guan@).
  • AI Gateway fallback: Auto-discovered gateway URLs are now probed for reachability (2s timeout GET). Workspaces without AI Gateway gracefully fall back to {DATABRICKS_HOST}/serving-endpoints/anthropic. Probe result cached in _GATEWAY_RESOLVED env var so setup subprocesses skip re-probing.

Changes

File What
app.py .lower() in get_token_owner(), get_request_user(), WebSocket auth; resolve_and_cache_gateway() calls in run_setup() and _configure_all_cli_auth()
utils.py _probe_gateway(), resolve_and_cache_gateway(), Tier 0 _GATEWAY_RESOLVED check in get_gateway_host()
tests/test_gateway_discovery.py 3 new Tier 0 cache tests, probe mocks on Tier 2 tests, _GATEWAY_RESOLVED in integration test env

Test plan

  • pytest tests/test_gateway_discovery.py::TestGetGatewayHost — 12 pass
  • pytest tests/test_ws_authorization.py — 16 pass
  • Deploy to workspace without AI Gateway — verify fallback to serving-endpoints
  • Verify user with mixed-case email can access their CODA instance

This pull request was AI-assisted by Isaac.

Two fixes for CODA deployments:

1. Normalize all emails to lowercase at ingestion points (get_token_owner,
   get_request_user, WebSocket auth) so SSO header casing differences
   don't cause authorization failures.

2. Probe auto-discovered AI Gateway URLs for reachability (2s timeout)
   before using them. Workspaces without AI Gateway gracefully fall back
   to {DATABRICKS_HOST}/serving-endpoints/anthropic. Result cached in
   _GATEWAY_RESOLVED env var so subprocesses skip re-probing.

Co-authored-by: Isaac
@datasciencemonkey
Copy link
Copy Markdown
Owner

Hey @dgokeeffe 👋

Thanks for this PR — both fixes are solid and exactly what we needed. I've cherry-picked your commit onto the current main (v0.17.0) in #123. Clean cherry-pick, no conflicts, all 182 tests pass.

Your original authorship is preserved on the commit. Closing this one in favor of #123.

datasciencemonkey added a commit that referenced this pull request Apr 14, 2026
Cherry-pick of #114 by David O'Keeffe (@dgokeeffe), rebased onto v0.17.0.

1. Normalize all emails to lowercase at ingestion points so SSO header
   casing differences don't cause authorization failures.
2. Probe auto-discovered AI Gateway URLs for reachability (2s timeout).
   Workspaces without AI Gateway gracefully fall back to serving-endpoints.
   Result cached in _GATEWAY_RESOLVED env var so subprocesses skip re-probing.
3. Version bump to 0.17.1.

Co-authored-by: David O'Keeffe <david.okeeffe@databricks.com>
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.

2 participants