Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .test_durations_slm
Original file line number Diff line number Diff line change
Expand Up @@ -4630,4 +4630,4 @@
"autobot-slm-backend/user_management/services/sso_secrets_test.py::TestSSOSecretsManagerIntegration::test_store_secrets_handles_empty_secret_values": 0.052052079000077356,
"autobot-slm-backend/user_management/services/sso_secrets_test.py::TestSSOSecretsManagerIntegration::test_store_secrets_handles_multiple_sensitive_fields": 0.07525764299998627,
"autobot-slm-backend/user_management/services/sso_secrets_test.py::TestSSOSecretsManagerIntegration::test_store_secrets_updates_existing_secret": 0.0896826289999808
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright 2025-2026 mrveiss
# SPDX-License-Identifier: Apache-2.0
# AutoBot - AI-Powered Automation Platform
# Author: mrveiss
"""Org conversation review audits every transcript open and stops at the org boundary (#17832).

The org-review screen only calls ``GET /chat/sessions/{id}``; the gate and the audit trail
are ``SessionOwnershipValidator``'s. These pin the two claims the screen relies on instead of
assuming them: an org admin opening a session in their own org writes a
``conversation_accessed`` audit record naming them, and a session in another org is not
served and writes no success record.
"""

from unittest.mock import AsyncMock, MagicMock, patch

import pytest

from security.session_ownership import SessionOwnershipValidator

SESSION_ID = "0123456789abcdef0123456789abcdef"


def _validator(session_org: str) -> SessionOwnershipValidator:
validator = SessionOwnershipValidator.__new__(SessionOwnershipValidator)
validator.get_session_context = AsyncMock(return_value={"org_id": session_org})
validator.is_shared_with_user = AsyncMock(return_value=False)
validator._handle_unauthorized_access = AsyncMock(return_value={"authorized": False})
return validator


async def _open(validator: SessionOwnershipValidator, role: str, org_id: str):
audit = MagicMock()
middleware = MagicMock()
middleware.security_layer.audit_log = audit
request = MagicMock()
request.client.host = "203.0.113.7"
enforcement = MagicMock(mode="enforced")
user = {"username": "reviewer", "user_id": "u-1", "role": role, "org_id": org_id}
with patch("security.session_ownership.get_auth_middleware", return_value=middleware):
result = await validator._check_ownership_mismatch(
"reviewer", SESSION_ID, "someone-else", user, request, enforcement
)
return result, audit


@pytest.mark.asyncio
@pytest.mark.parametrize("role", ["admin", "org_admin"])
async def test_org_admin_open_is_audit_logged_with_the_reviewer(role):
result, audit = await _open(_validator("org-1"), role, "org-1")

assert result["authorized"] is True
assert result["reason"] == "org_admin"
audit.assert_called_once()
kwargs = audit.call_args.kwargs
assert kwargs["action"] == "conversation_accessed"
assert kwargs["user"] == "reviewer"
assert kwargs["outcome"] == "success"
assert kwargs["details"]["session_id"].startswith(SESSION_ID[:16])


@pytest.mark.asyncio
async def test_a_session_in_another_org_is_not_served_and_not_logged_as_a_success():
validator = _validator("org-2")
result, audit = await _open(validator, "admin", "org-1")

assert result == {"authorized": False}
validator._handle_unauthorized_access.assert_awaited_once()
assert all(call.kwargs.get("action") != "conversation_accessed" for call in audit.call_args_list)


@pytest.mark.asyncio
async def test_a_non_admin_role_is_not_served_even_inside_its_own_org():
validator = _validator("org-1")
result, audit = await _open(validator, "user", "org-1")

assert result == {"authorized": False}
assert all(call.kwargs.get("action") != "conversation_accessed" for call in audit.call_args_list)
58 changes: 58 additions & 0 deletions autobot-frontend/src/composables/useOrgConversationReview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2025-2026 mrveiss
// SPDX-License-Identifier: Apache-2.0
// AutoBot - AI-Powered Automation Platform
// Author: mrveiss
/**
* Org-scoped conversation review (#17832).
*
* Two existing, server-gated reads, typed from the generated contract (`paths`):
* - `GET /api/chat/sessions?scope=org` the caller's own organization's sessions
* - `GET /api/chat/sessions/{session_id}` one transcript, page by page
* The server is the authority for both: the list refuses a caller without an
* administrative role, a transcript is served only when the session's org matches
* the caller's, and every transcript open is written to the audit trail by
* `SessionOwnershipValidator`. This module adds no access of its own.
*/
import type { paths } from '@/types/generated/api'
import { useApiClient } from '@/plugins/api'
import { getApiBase } from '@/config/ssot-config'

type Body<P extends keyof paths> = paths[P] extends {
get: { responses: { 200: { content: { 'application/json': infer J } } } }
}
? J
: never

const SESSIONS_PATH = '/api/chat/sessions' as const
const SESSION_PATH = '/api/chat/sessions/{session_id}' as const

/** The contract path, rebased on the configured API base (the SSOT, never a literal). */
const url = (contractPath: string): string => `${getApiBase()}${contractPath.slice('/api'.length)}`

export type OrgSessionsResponse = Body<typeof SESSIONS_PATH>
export type TranscriptResponse = Body<typeof SESSION_PATH>
export type OrgSessionsData = NonNullable<OrgSessionsResponse['data']>
export type OrgSession = OrgSessionsData['sessions'][number]
export type TranscriptData = NonNullable<TranscriptResponse['data']>
export type TranscriptMessage = TranscriptData['messages'][number]

/** Messages per transcript page; the backend accepts a caller-chosen size. */
export const TRANSCRIPT_PAGE_SIZE = 50

export function useOrgConversationReview() {
const api = useApiClient()

async function listOrgSessions(): Promise<OrgSessionsData | null> {
const body = (await api.get(`${url(SESSIONS_PATH)}?scope=org`)) as OrgSessionsResponse
return body?.data ?? null
}

async function openTranscript(sessionId: string, page: number): Promise<TranscriptData | null> {
const path = SESSION_PATH.replace('{session_id}', encodeURIComponent(sessionId))
const query = `page=${page}&per_page=${TRANSCRIPT_PAGE_SIZE}`
const body = (await api.get(`${url(path)}?${query}`)) as TranscriptResponse
return body?.data ?? null
}

return { listOrgSessions, openTranscript }
}
2 changes: 2 additions & 0 deletions autobot-frontend/src/config/navItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export const adminMenuItems: NavItem[] = [
{ to: '/admin/mcp-servers', labelKey: 'nav.adminMcpServers', icon: 'M21.75 17.25v-.228a4.5 4.5 0 00-.12-1.03l-2.268-9.64a3.375 3.375 0 00-3.285-2.602H7.923a3.375 3.375 0 00-3.285 2.602l-2.268 9.64a4.5 4.5 0 00-.12 1.03v.228m19.5 0a3 3 0 01-3 3H5.25a3 3 0 01-3-3m19.5 0a3 3 0 00-3-3H5.25a3 3 0 00-3 3', iconViewBox: '0 0 24 24', iconStroke: true },
// Issue #16825: permission scopes -- a "coming in a later release" panel, not a working
// feature yet, unlike the two entries above.
// Issue #17832: org conversation review -- the server gates and audits; this entry is presentation only.
{ to: '/admin/conversations', labelKey: 'nav.adminConversations', icon: 'M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z', iconViewBox: '0 0 24 24', iconStroke: true },
{ to: '/admin/permission-scopes', labelKey: 'nav.adminPermissionScopes', icon: 'M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z', iconViewBox: '0 0 24 24', iconStroke: true },
];

Expand Down
33 changes: 32 additions & 1 deletion autobot-frontend/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8321,7 +8321,8 @@
"degradedMessage": "Some backend services are slow or failing. Features may not work as expected.",
"criticalTitle": "Backend unreachable",
"criticalMessage": "AutoBot cannot reach its backend. Changes may not be saved until it is back."
}
},
"adminConversations": "Conversation Review"
},
"llcCompanyStatus": {
"showArchived": "Show archived",
Expand Down Expand Up @@ -9889,6 +9890,36 @@
"title": "Administration",
"subtitle": "Back-office tools for administrators",
"ariaLabel": "Administration section"
},
"conversations": {
"title": "Conversation Review",
"subtitle": "Review conversations in your organization. Access is decided by the server.",
"auditNotice": "Every transcript you open is recorded in the audit trail. You see only sessions that belong to your own organization.",
"openAudited": "Opening this transcript has been recorded in the audit trail.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Do not state that a transcript open is recorded during loading or after a failed read.

The notice at AdminConversationsView.vue:185 renders outside every condition. It appears while the transcript loads and after refused, failed, and missing reads. Some of these reads can end before any audit call. For example, the authentication check that returns 401 runs before the audit call. The notice still says the open was recorded. A successful read also does not confirm a durable record, so the wording must not promise one in any state.

Replace the string with wording that does not claim a completed record:

Suggested fix

-      "openAudited": "Opening this transcript has been recorded in the audit trail.",
+      "openAudited": "Transcript opens may be recorded in the audit trail.",
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
"openAudited": "Opening this transcript has been recorded in the audit trail.",
"openAudited": "Transcript opens may be recorded in the audit trail.",

"colTitle": "Conversation",
"colMessages": "Messages",
"colUpdated": "Last updated",
"colId": "Session ID",
"untitled": "Untitled conversation",
"openTranscript": "Open transcript",
"transcript": "Transcript",
"loading": "Loading organization conversations",
"emptyTitle": "No conversations in your organization",
"emptyBody": "Sessions that belong to your organization appear here once they exist.",
"noOrgTitle": "Your account is not part of an organization",
"noOrgBody": "Organization review is not available because the server found no organization for your account.",
"refusedTitle": "The server refused this request",
"refusedBody": "Listing organization conversations needs an administrative role. Your role does not allow it.",
"failedTitle": "Could not load",
"failedBody": "The conversation list could not be loaded. Try again.",
"transcriptRefusedTitle": "The server refused access to this conversation",
"transcriptRefusedBody": "A transcript opens only for an administrator of the organization that owns the session.",
"transcriptMissing": "This conversation no longer exists.",
"transcriptFailedBody": "The transcript could not be loaded. Try again.",
"noMessagesTitle": "No messages",
"noMessagesBody": "This conversation has no messages on this page.",
"unknownSender": "Unknown sender",
"transcriptPages": "Transcript pages"
}
},
"components": {
Expand Down
2 changes: 2 additions & 0 deletions autobot-frontend/src/router/__tests__/adminRoutes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const OLD_ADMIN_PATHS: Record<string, string> = {
'/admin/pricing': 'admin-pricing',
'/admin/mcp-servers': 'admin-mcp-servers',
'/admin/permission-scopes': 'admin-permission-scopes',
'/admin/conversations': 'admin-conversations',
}

const OLD_COMPONENT_FILES: Record<string, string> = {
Expand All @@ -51,6 +52,7 @@ const OLD_COMPONENT_FILES: Record<string, string> = {
'admin-pricing': 'AdminPricingView.vue',
'admin-mcp-servers': 'AdminMcpServersView.vue',
'admin-permission-scopes': 'AdminPermissionScopesView.vue',
'admin-conversations': 'AdminConversationsView.vue',
}

function adminTo(): RouteLocationNormalized {
Expand Down
8 changes: 8 additions & 0 deletions autobot-frontend/src/router/adminRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export const adminChildren: RouteRecordRaw[] = [
component: () => import('@/views/AdminMcpServersView.vue'),
meta: adminMeta('MCP Servers'),
},
{
path: 'conversations', // Issue #17832: org-scoped conversation review (server-gated, audited)
name: 'admin-conversations',
component: () => import('@/views/AdminConversationsView.vue'),
meta: adminMeta('Conversation Review', {
description: 'Review conversations in your organization',
Comment on lines +105 to +106

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Supported by static analysis

Script executed:

sed -n '1,165p' autobot-frontend/src/router/adminRoutes.ts
cat autobot-frontend/src/utils/documentTitle.ts
rg -n 'titleKey|meta.title|setDocumentTitle|i18n.global.t' autobot-frontend/src/router/index.ts autobot-frontend/src/router/*Routes.ts

Repository: mrveiss/AutoBot-AI

Length of output: 6583


Resolve the Conversation Review tab title through i18n.

The admin-conversations route passes the literal 'Conversation Review' as meta.title. The global guard passes that value to setDocumentTitle, which writes it into document.title without translation. The page heading already uses admin.conversations.title, so the literal duplicates an existing i18n entry. The project path instruction requires routing user-facing strings through i18n.

The tab title stays English until translations for this key are added. The defect becomes visible at that point.

A focused fix does not need to change sibling admin routes. Resolve this route's title key when each navigation runs, and keep the literal titles of sibling routes as they are. Do not compute the translated value when adminRoutes.ts loads, because that fixes the title to the locale active at load time. router/index.ts is at its size ceiling, so keep changes in that file minimal. The title value at router/index.ts:1264 feeds analytics, so keep that consumer working after any change to the title field.

}),
},
{
path: 'permission-scopes', // Issue #16825: "coming later" panel
name: 'admin-permission-scopes',
Expand Down
Loading
Loading