larry-zy commented on PR #1610: URL: https://github.com/apache/dubbo-admin/pull/1610#issuecomment-6380449712
**[P2] Keep session ownership separate from the authorized caller** Reviewed head: `2a51ff9bb18bb16c51fcdd262c3aa76d09a2010c`. The ownership predicate in [`ai/component/context/compiler.go:224`](https://github.com/apache/dubbo-admin/blob/2a51ff9bb18bb16c51fcdd262c3aa76d09a2010c/ai/component/context/compiler.go#L224-L232) requires every item owner to equal the current caller: ```go item.OwnerID == req.Access.Subject.UserID ``` However, the existing authorization contract grants `ai:sessions:admin` access to other owners within the same tenant. `ContextTurns` correctly retains the Session's real `OwnerID`. A same-tenant administrator can therefore pass Session/Store authorization and start an interaction, but compilation rejects the mandatory current-input item with `resource not accessible` before the model call. I reproduced this at the reviewed head: create a Session as one user, construct a different same-tenant caller with `ai:sessions:admin`, successfully read the Session and initialize the interaction, then compile its context. The Store accepts the operation while the Compiler rejects it. The same actor/owner conflation also occurs when constructing the canonical tool ledger in [`ai/component/agent/react/tool_records.go:32`](https://github.com/apache/dubbo-admin/blob/2a51ff9bb18bb16c51fcdd262c3aa76d09a2010c/ai/component/agent/react/tool_records.go#L31-L33): ```go batch := store.ToolBatch{ID: uuid.NewString(), TenantID: state.access.Subject.TenantID, OwnerID: state.access.Subject.UserID, SessionID: s.Session, TurnID: state.turnID, InteractionID: state.interactionID, Sequence: uint64(s.Iteration), Version: 1, SchemaVersion: "v1"} ``` Both backend `CreateToolBatch` implementations compare this owner against the Session owner, so relaxing only the Compiler predicate would leave authorized administrator tool calls failing. Please carry the canonical Session owner separately from the acting subject, validate item/batch provenance against that Session, and apply the existing ownership policy to the caller. Preserve the cross-tenant denial. Add regressions for administrator context compilation and canonical tool execution, alongside ordinary-owner and unauthorized-caller cases. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
