feat(session): implement strict owner scope for API-key sessions
Add GetOwnedSession method to enforce strict ownership checks for session mutations, ensuring tenant admins can read but not modify API-key sessions. Update relevant handlers to utilize this method for operations that alter session data, maintaining security and integrity of API-key sessions.
This commit is contained in:
@@ -258,8 +258,10 @@ func (h *Handler) StopSession(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// Verify message belongs to the current tenant
|
||||
session, err := h.sessionService.GetSession(ctx, sessionID)
|
||||
// Verify message belongs to the current tenant. Stopping generation mutates
|
||||
// an in-flight run, so use the strict owner scope: a tenant admin may read an
|
||||
// API-key session but must not be able to interrupt its (external) API calls.
|
||||
session, err := h.sessionService.GetOwnedSession(ctx, sessionID)
|
||||
if err != nil {
|
||||
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
||||
"session_id": sessionID,
|
||||
|
||||
Reference in New Issue
Block a user