Skip to content

[ML-62918] Auto-detect OBO endpoints and forward user token#145

Open
dhruv0811 wants to merge 6 commits intomainfrom
obo-auto-detection
Open

[ML-62918] Auto-detect OBO endpoints and forward user token#145
dhruv0811 wants to merge 6 commits intomainfrom
obo-auto-detection

Conversation

@dhruv0811
Copy link
Contributor

@dhruv0811 dhruv0811 commented Mar 3, 2026

Summary

Auto-detect OBO-enabled serving endpoints and surface scope configuration to the user.

This is a followup to #152 which only addressed the Agents on Apps token forwarding. In this PR, we also address apps connected directly to a model serving endpoint.

Detection:

  • Detect OBO via auth_policy.user_auth_policy.api_scopes (custom endpoints) or tile_endpoint_metadata.problem_type === "MULTI_AGENT_SUPERVISOR" (Supervisor Agents)
  • Always include serving.serving-endpoints in required scopes (needed to call the endpoint as the user)
  • Log a warning with required scopes at startup

Token forwarding:

  • When OBO is detected, replace the app SP's Authorization header with the user's x-forwarded-access-token so the endpoint sees the user's identity
  • Forward x-forwarded-access-token through streamText headers in the chat route

Smart banner:

  • Decode the user's JWT token server-side to check which scopes are already present
  • Only show banner for missing scopes — disappears when all required scopes are configured
  • Parent scope matching: sql satisfies sql.statement-execution and sql.warehouses
  • Full-width red banner with error icon and link to auth docs
  • Exposed via GET /api/configobo.missingScopes

Note: UC function scopes are not yet supported in the Apps scope configuration UI.

No scopes enabled on app connected to serving endpoint that requires scopes:
Before

Logs:
Logs

After adding partially required scopes (error message updates after checking whats on the token):
After one scope

After adding ALL required scopes:
After configuring required scopes

Still works for OBO on Agents on Apps:
Still Works for Apps

@dhruv0811 dhruv0811 force-pushed the obo-auto-detection branch from eb21e57 to 0e82c5b Compare March 5, 2026 21:52
@dhruv0811 dhruv0811 requested a review from bbqiu March 6, 2026 22:41
@dhruv0811 dhruv0811 changed the title Auto-detect OBO endpoints and forward user token [ML-62918] Auto-detect OBO endpoints and forward user token Mar 6, 2026
@dhruv0811 dhruv0811 requested a review from smurching March 6, 2026 22:42
@dhruv0811 dhruv0811 requested a review from bbqiu March 17, 2026 15:58
Copy link
Contributor

@bbqiu bbqiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks great! just a few nits to address, sorry for the dealy in reviewing

@dhruv0811
Copy link
Contributor Author

New SA banner:
Screenshot 2026-03-20 at 1 32 47 PM
ps: love the new chat UI!

All the same configuration as the PR summary also still work, comments addressed.

@dhruv0811 dhruv0811 requested a review from bbqiu March 20, 2026 20:33
Comment on lines +39 to +50
const userToken = req.headers['x-forwarded-access-token'] as string | undefined;
if (userToken && oboInfo.enabled) {
const payload = decodeJwtPayload(userToken);
if (payload) {
// Databricks OAuth tokens use 'scope' (space-separated string)
const tokenScopes = typeof payload.scope === 'string'
? payload.scope.split(' ')
: Array.isArray(payload.scp) ? payload.scp as string[] : [];
// A required scope like "sql.statement-execution" is satisfied by
// an exact match OR by its parent prefix (e.g. "sql")
missingScopes = oboInfo.requiredScopes.filter(required => {
const parent = required.split('.')[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: to make this slightly cleaner, can we make a helper function that goes from oauth token -> scopes

and then we can do the same comparison between present / required scopes

@dhruv0811 dhruv0811 force-pushed the obo-auto-detection branch 2 times, most recently from c757dbd to f9bc45d Compare March 20, 2026 22:58
dhruv0811 and others added 5 commits March 20, 2026 18:07
When the serving endpoint has auth_policy.user_auth_policy.api_scopes
(OBO-enabled), the chat template now:

1. Detects OBO via the serving-endpoints API response
2. Logs a warning with required scopes for the user to configure
3. Exposes OBO status via GET /api/config
4. Forwards x-forwarded-access-token header to the endpoint

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When the serving endpoint has OBO scopes (auth_policy.user_auth_policy),
display an amber badge in the chat header listing the required scopes
and linking to the auth docs. Also notes that UC function scopes are
not yet supported.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Always include serving.serving-endpoints in required OBO scopes
- Detect Supervisor Agents via tile_endpoint_metadata.problem_type
- Decode user JWT server-side to check which scopes are present
- Only show banner for MISSING scopes (disappears when all configured)
- Parent scope matching (e.g. "sql" satisfies "sql.statement-execution")
- Full-width red banner with error icon and doc link
- Use user's OBO token as Authorization when endpoint supports OBO
- Remove debug logging

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Supervisor Agents may require scopes beyond serving.serving-endpoints
for their downstream tools (Genie, SQL, etc.). Full scope discovery
for SAs is not yet available. Updated banner and log to communicate
this limitation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…docs link

- Always use user token for Authorization when present (remove cachedOboEnabled)
- Keep x-forwarded-access-token header for downstream agent apps
- Store isSupervisorAgent in cache to fix broken length === 0 detection
- Update docs link to specific OBO section

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dhruv0811 dhruv0811 force-pushed the obo-auto-detection branch from f9bc45d to e1ca982 Compare March 21, 2026 01:12
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dhruv0811 dhruv0811 requested a review from bbqiu March 21, 2026 01:19
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