feat(embed): scope OAuth and sessions per visitor principal

Add embed visitor principals (X-Embed-Visitor), widen sessions.user_id,
embed MCP OAuth/approval routes, OAuth callback context detachment, and
CloneContext principal preservation for async QA streams.
This commit is contained in:
wizardchen
2026-06-30 18:16:44 +08:00
committed by lyingbug
parent 168b1d4cfe
commit 5074344c16
23 changed files with 438 additions and 43 deletions
@@ -99,8 +99,8 @@ func (s *sessionService) KnowledgeQA(
len(searchTargets),
)
// Get UserID from context
userID, _ := types.UserIDFromContext(ctx)
// Scope memory and pipeline attribution to the same owner as the session.
userID := types.SessionOwnerIDFromContext(ctx)
chatManage := &types.ChatManage{
PipelineRequest: types.PipelineRequest{
@@ -734,7 +734,7 @@ func (s *sessionService) SearchKnowledge(ctx context.Context,
}
// Create default retrieval parameters — prefer tenant RetrievalConfig, fallback to built-in defaults
userID, _ := types.UserIDFromContext(ctx)
userID := types.SessionOwnerIDFromContext(ctx)
// Load tenant-level retrieval config (nil is safe — GetEffective* methods handle nil receiver)
var rc *types.RetrievalConfig