feat: scope API MCP OAuth by principal
This commit is contained in:
@@ -392,13 +392,13 @@ func (e *AgentEngine) runToolCall(
|
||||
},
|
||||
})
|
||||
|
||||
userID, _ := types.UserIDFromContext(ctx)
|
||||
principal, _ := types.PrincipalFromContext(ctx)
|
||||
toolExecCtx := agenttools.WithToolExecContext(toolCtx, &agenttools.ToolExecContext{
|
||||
SessionID: sessionID,
|
||||
AssistantMessageID: assistantMessageID,
|
||||
EventBus: e.eventBus,
|
||||
ToolCallID: tc.ID,
|
||||
UserID: userID,
|
||||
UserID: principal.StorageID(),
|
||||
// ApprovalCtx keeps the round-level ctx without the per-tool 60s timeout,
|
||||
// so MCP tool human-approval (issue #1173) can legitimately block longer.
|
||||
ApprovalCtx: toolCtx,
|
||||
|
||||
@@ -15,7 +15,7 @@ type ToolExecContext struct {
|
||||
AssistantMessageID string
|
||||
RequestID string
|
||||
ToolCallID string
|
||||
UserID string // owner of the originating session; used by HITL gates for authorization (issue #1173)
|
||||
UserID string // principal storage ID of the originating session; used by HITL gates for authorization (issue #1173)
|
||||
EventBus *event.EventBus
|
||||
// ApprovalCtx is the parent ctx WITHOUT defaultToolExecTimeout; used when the tool
|
||||
// must wait for human approval that may exceed normal tool exec timeout (issue #1173).
|
||||
|
||||
@@ -65,7 +65,8 @@ func oauthSessionForRegistration(ctx context.Context, sess *MCPOAuthSession, ret
|
||||
}
|
||||
userID := sess.UserID
|
||||
if userID == "" {
|
||||
userID, _ = types.UserIDFromContext(ctx)
|
||||
principal, _ := types.PrincipalFromContext(ctx)
|
||||
userID = principal.StorageID()
|
||||
}
|
||||
requestID := sess.RequestID
|
||||
if requestID == "" {
|
||||
@@ -141,7 +142,8 @@ func waitForMCPOAuthAuthorization(
|
||||
tenantID, _ := types.TenantIDFromContext(ctx)
|
||||
userID := sess.UserID
|
||||
if userID == "" {
|
||||
userID, _ = types.UserIDFromContext(ctx)
|
||||
principal, _ := types.PrincipalFromContext(ctx)
|
||||
userID = principal.StorageID()
|
||||
}
|
||||
requestID := sess.RequestID
|
||||
if requestID == "" {
|
||||
|
||||
Reference in New Issue
Block a user