Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
| "client_id": {auth.DefaultClientID}, | ||
| "subject_token": {session.AccessToken}, | ||
| "subject_token_type": {"urn:ietf:params:oauth:token-type:access_token"}, | ||
| "resource": {entry.Provider}, |
There was a problem hiding this comment.
🟡 entry.Resource is parsed from credential template but silently ignored in token exchange
The credential template parser (internal/credential/credential.go:59) supports a provider/resource syntax (e.g., {{kontext:github/readonly}}), populating entry.Resource with the sub-resource specifier. However, exchangeCredential only sends entry.Provider in the resource form field at line 207 and completely ignores entry.Resource. This means if a user specifies {{kontext:github/readonly}}, the readonly scope is silently dropped from the token exchange request, and the returned token may have broader permissions than intended.
Prompt for agents
The credential template parser in internal/credential/credential.go supports provider/resource syntax (e.g., github/readonly), storing the resource part in entry.Resource. But exchangeCredential in internal/run/run.go:207 only uses entry.Provider as the resource form field and completely ignores entry.Resource.
Possible approaches:
1. Include entry.Resource as an additional form parameter (e.g., scope) in the token exchange request.
2. Combine provider and resource into the resource field, e.g., entry.Provider + "/" + entry.Resource when entry.Resource is non-empty.
3. If the server doesn't support resource sub-specifiers yet, add a warning log when entry.Resource is non-empty so users know it's being ignored.
The right approach depends on what the server-side token exchange endpoint supports.
Was this helpful? React with 👍 or 👎 to provide feedback.
Squashed PR #7 + #13 onto main after resolving squash-merge divergence. Changes from PR #7 (credential exchange): - Replace stub exchangeCredential with real RFC 8693 token exchange - Use session.IssuerURL for endpoint discovery (not hardcoded default) - Add Bearer auth header to token exchange requests - Fix filterArgs to handle --flag=value syntax (security: prevents --settings=evil.json from bypassing the governance hooks filter) - Add truncateID helper for safe session ID display Changes from PR #13 (token refresh): - Replace static access token with TokenSource function - Auto-refresh OIDC token during long-running sessions - Resolve credentials before starting sidecar (data race fix) Addresses Devin review findings on PR #7. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f4b56ab to
3df8073
Compare

Summary
DiscoverEndpointsandOAuthMetadatafrom the auth package sorun.gocan call OAuth discoveryexchangeCredentialstub with a real implementation that callsPOST /oauth2/tokenusing RFC 8693 token exchangesubject_token— no client secret needed (public client)access_tokenfield)Note
Based on
feat/governance-telemetry-pipeline— the credential exchange importsbackend,sidecar, and proto types introduced there. Should be merged after that branch lands on main.Test plan
kontext startwith a.env.kontextcontainingGITHUB_TOKEN={{kontext:github}}resolves credentials after backend gate is relaxed (kontext-dev/kontext#410)Depends on
🤖 Generated with Claude Code