Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
c3378fc
1
Parent(s): 4150e03
fix: restore portal identification and inclusive auth checks
Browse filesFiles changed (2)
118 unmodified lines119120121122123124125126127128129130131132133134135136137138139140118 unmodified linesraise credentials_exception# --- STRICT PORTAL ISOLATION (Backend Guard) ---# We use user.role (fetched from DB) to handle existing sessions that lack the 'role' claim in JWTfrom models.user import UserRoleif portal == "internal" and user.role not in [UserRole.SC_AGENT, UserRole.SC_LEAD, UserRole.SC_ADMIN]:# Log this attempt for security auditimport logginglogging.getLogger("security").warning(f"BLOCKED: Customer {user.email} attempted internal portal API access")raise HTTPException(status_code=status.HTTP_403_FORBIDDEN,detail="Access Denied: Customers cannot access internal operations endpoints.")elif portal == "customer" and user.role not in [UserRole.CUSTOMER_ADMIN, UserRole.CUSTOMER_USER, UserRole.SC_ADMIN]:# Staff can only access the customer portal if they are SC_ADMIN (Super Admin)raise HTTPException(status_code=status.HTTP_403_FORBIDDEN,detail="Access Denied: Staff must use the Operations Console.")from uuid import UUIDsetattr(user, "workspace_id", UUID(active_ws_id) if active_ws_id else None)118 unmodified lines119120121122123124125126127128129130131132133134135136137138139140141142118 unmodified linesraise credentials_exception# --- STRICT PORTAL ISOLATION (Backend Guard) ---# We use prefix-based checks (inclusive) to allow for legacy roles like 'customer'role_str = str(user.role).lower() if user.role else ""if portal == "internal":if not role_str.startswith("3sc_"):import logginglogging.getLogger("security").warning(f"BLOCKED: Customer {user.email} (Role: {role_str}) attempted internal portal API access")raise HTTPException(status_code=status.HTTP_403_FORBIDDEN,detail="Access Denied: Customers cannot access internal operations endpoints.")elif portal == "customer":if role_str.startswith("3sc_") and role_str != "3sc_admin":# Direct Staff users to the Operations Console, but allow Super Admins (3sc_admin)raise HTTPException(status_code=status.HTTP_403_FORBIDDEN,detail="Access Denied: Staff must use the Operations Console.")from uuid import UUIDsetattr(user, "workspace_id", UUID(active_ws_id) if active_ws_id else None)
5 unmodified lines6789101112135 unmodified linesuseAIInsights,useServiceNarrative,LoginCard,NexusLogo} from '@nexus/shared';import { SideNav } from './components/SideNav';import type { TabId } from './components/SideNav';import { TopBar } from './components/TopBar';5 unmodified lines6789101112131415165 unmodified linesuseAIInsights,useServiceNarrative,LoginCard,NexusLogo,setPortalType} from '@nexus/shared';setPortalType('internal');import { SideNav } from './components/SideNav';import type { TabId } from './components/SideNav';import { TopBar } from './components/TopBar';
core/deps.py+18-16
frontend/apps/internal/src/App.tsx+4-1