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
+2
View File
@@ -499,6 +499,7 @@ func CloneContext(ctx context.Context) context.Context {
types.TenantInfoContextKey,
types.UserIDContextKey,
types.UserContextKey,
types.PrincipalContextKey,
// TenantRoleContextKey: the caller's resolved role in the
// active tenant (PR 2 #1303). Must be propagated for the same
// reason as TenantIDContextKey — any handler that does
@@ -510,6 +511,7 @@ func CloneContext(ctx context.Context) context.Context {
types.LanguageContextKey,
types.SessionTenantIDContextKey,
types.EmbedQueryContextKey,
types.EmbedVisitorContextKey,
// Keep the Langfuse trace alive across CloneContext boundaries so
// LLM/Embedder/Reranker/VLM/ASR wrappers attach their generations
// to the same trace opened by GinMiddleware, instead of each call