Spaces:
Sleeping
Sleeping
Commit
Β·
db5de26
1
Parent(s):
dc11950
update the readme file
Browse files
README.md
CHANGED
|
@@ -71,8 +71,10 @@ Then access:
|
|
| 71 |
- **Gradio UI**: `http://localhost:7860`
|
| 72 |
- **FastAPI Docs**: `http://localhost:8000/docs`
|
| 73 |
- **Next.js Frontend** (optional): `cd frontend && npm install && npm run dev` β `http://localhost:3000`
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
> **Security Note:** REST requests that hit protected endpoints must include both `x-tenant-id` and `x-user-role` headers. Roles (`viewer`, `editor`, `admin`, `owner`) determine which actionsβsuch as document ingestion, rule uploads, or analytics accessβthe caller may perform.
|
| 76 |
|
| 77 |
---
|
| 78 |
|
|
@@ -102,6 +104,7 @@ Then access:
|
|
| 102 |
- LLM token logs and latency metrics
|
| 103 |
- π **Live Web Search** β Google Programmable Search (Custom Search API) with tenant-aware MCP tooling
|
| 104 |
- π’ **Multi-Tenant Isolation** β Complete tenant isolation with centralized tenant ID management; backend enforces strict isolation for chat, ingestion, and admin ops
|
|
|
|
| 105 |
- π **Intelligent Multi-Tool Orchestration** β MCP agent orchestrator autonomously selects optimal tool chains (RAG + Web + LLM, etc.) based on query intent and context
|
| 106 |
- β‘ **Robust Error Handling** β Structured error responses, retry mechanisms, and graceful fallbacks (e.g., if RAG fails β fallback to LLM-only)
|
| 107 |
- π‘ **Streaming Responses** β Chat responses stream word-by-word using Server-Sent Events (SSE) for real-time user experience
|
|
@@ -147,6 +150,116 @@ Subsequent tool calls with the same `session_id` will receive a `memory` field c
|
|
| 147 |
|
| 148 |
---
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
## Installation & Setup
|
| 151 |
|
| 152 |
### Prerequisites
|
|
|
|
| 71 |
- **Gradio UI**: `http://localhost:7860`
|
| 72 |
- **FastAPI Docs**: `http://localhost:8000/docs`
|
| 73 |
- **Next.js Frontend** (optional): `cd frontend && npm install && npm run dev` β `http://localhost:3000`
|
| 74 |
+
- Use the role selector in the header to switch between viewer, editor, admin, or owner roles
|
| 75 |
+
- UI automatically shows/hides features based on selected role
|
| 76 |
|
| 77 |
+
> **Security Note:** REST requests that hit protected endpoints must include both `x-tenant-id` and `x-user-role` headers. Roles (`viewer`, `editor`, `admin`, `owner`) determine which actionsβsuch as document ingestion, rule uploads, or analytics accessβthe caller may perform. The Next.js frontend automatically sends the selected role in all API requests.
|
| 78 |
|
| 79 |
---
|
| 80 |
|
|
|
|
| 104 |
- LLM token logs and latency metrics
|
| 105 |
- π **Live Web Search** β Google Programmable Search (Custom Search API) with tenant-aware MCP tooling
|
| 106 |
- π’ **Multi-Tenant Isolation** β Complete tenant isolation with centralized tenant ID management; backend enforces strict isolation for chat, ingestion, and admin ops
|
| 107 |
+
- π **Fine-Grained Role-Based Access Control (RBAC)** β Four-tier role system (viewer, editor, admin, owner) with dynamic UI visibility and backend permission enforcement; frontend automatically shows/hides features based on role
|
| 108 |
- π **Intelligent Multi-Tool Orchestration** β MCP agent orchestrator autonomously selects optimal tool chains (RAG + Web + LLM, etc.) based on query intent and context
|
| 109 |
- β‘ **Robust Error Handling** β Structured error responses, retry mechanisms, and graceful fallbacks (e.g., if RAG fails β fallback to LLM-only)
|
| 110 |
- π‘ **Streaming Responses** β Chat responses stream word-by-word using Server-Sent Events (SSE) for real-time user experience
|
|
|
|
| 150 |
|
| 151 |
---
|
| 152 |
|
| 153 |
+
## Role-Based Access Control (RBAC)
|
| 154 |
+
|
| 155 |
+
IntegraChat implements fine-grained role-based access control (RBAC) for both backend API endpoints and frontend UI. This ensures that users only see and can access features appropriate for their role level.
|
| 156 |
+
|
| 157 |
+
### Roles
|
| 158 |
+
|
| 159 |
+
The system supports four roles with increasing privileges:
|
| 160 |
+
|
| 161 |
+
1. **viewer** (default) - Basic read-only access
|
| 162 |
+
- Can use chat functionality
|
| 163 |
+
- Cannot ingest documents
|
| 164 |
+
- Cannot delete documents
|
| 165 |
+
- Cannot view analytics
|
| 166 |
+
- Cannot manage admin rules
|
| 167 |
+
|
| 168 |
+
2. **editor** - Content management access
|
| 169 |
+
- Can use chat functionality
|
| 170 |
+
- β
Can ingest documents (upload, paste, URLs, files)
|
| 171 |
+
- β Cannot delete documents
|
| 172 |
+
- β Cannot view analytics
|
| 173 |
+
- β Cannot manage admin rules
|
| 174 |
+
|
| 175 |
+
3. **admin** - Administrative access
|
| 176 |
+
- Can use chat functionality
|
| 177 |
+
- β
Can ingest documents
|
| 178 |
+
- β
Can delete documents
|
| 179 |
+
- β
Can view analytics
|
| 180 |
+
- β
Can manage admin rules
|
| 181 |
+
|
| 182 |
+
4. **owner** - Full system access
|
| 183 |
+
- Same permissions as admin (highest privilege level)
|
| 184 |
+
|
| 185 |
+
### Permission Matrix
|
| 186 |
+
|
| 187 |
+
| Action | viewer | editor | admin | owner |
|
| 188 |
+
|--------|--------|--------|-------|-------|
|
| 189 |
+
| Chat Bot | β
| β
| β
| β
|
|
| 190 |
+
| Ingest Documents | β | β
| β
| β
|
|
| 191 |
+
| Delete Documents | β | β | β
| β
|
|
| 192 |
+
| View Analytics | β | β | β
| β
|
|
| 193 |
+
| Manage Rules | β | β | β
| β
|
|
| 194 |
+
|
| 195 |
+
### Backend RBAC
|
| 196 |
+
|
| 197 |
+
Backend API endpoints enforce RBAC through the `x-user-role` header:
|
| 198 |
+
|
| 199 |
+
```python
|
| 200 |
+
# Permission matrix in backend/mcp_server/common/access_control.py
|
| 201 |
+
PERMISSIONS = {
|
| 202 |
+
"manage_rules": {"owner", "admin"},
|
| 203 |
+
"ingest_documents": {"owner", "admin", "editor"},
|
| 204 |
+
"delete_documents": {"owner", "admin"},
|
| 205 |
+
"view_analytics": {"owner", "admin"},
|
| 206 |
+
}
|
| 207 |
+
```
|
| 208 |
+
|
| 209 |
+
**Protected Endpoints:**
|
| 210 |
+
- `/admin/rules` - Requires `admin` or `owner` role
|
| 211 |
+
- `/rag/ingest*` - Requires `editor`, `admin`, or `owner` role
|
| 212 |
+
- `/rag/delete*` - Requires `admin` or `owner` role
|
| 213 |
+
- `/analytics/*` - Requires `admin` or `owner` role
|
| 214 |
+
|
| 215 |
+
**Example Request:**
|
| 216 |
+
```bash
|
| 217 |
+
curl -X POST "http://localhost:8000/admin/rules" \
|
| 218 |
+
-H "Content-Type: application/json" \
|
| 219 |
+
-H "x-tenant-id: tenant123" \
|
| 220 |
+
-H "x-user-role: admin" \
|
| 221 |
+
-d '{"rule": "Do not share passwords"}'
|
| 222 |
+
```
|
| 223 |
+
|
| 224 |
+
If the role lacks permission, the API returns `403 Forbidden` with a descriptive error message.
|
| 225 |
+
|
| 226 |
+
### Frontend RBAC
|
| 227 |
+
|
| 228 |
+
The frontend UI dynamically shows/hides features based on the selected role:
|
| 229 |
+
|
| 230 |
+
**Role Selector:**
|
| 231 |
+
- Located in the header navigation
|
| 232 |
+
- Dropdown to switch between roles (viewer, editor, admin, owner)
|
| 233 |
+
- Role is persisted in localStorage
|
| 234 |
+
- Changes take effect immediately across all pages
|
| 235 |
+
|
| 236 |
+
**Conditional UI Visibility:**
|
| 237 |
+
- **Navigation Links**: Only relevant links shown (e.g., editor doesn't see "Analytics" or "Admin Rules")
|
| 238 |
+
- **Page Sections**: Entire sections hidden if user lacks permission
|
| 239 |
+
- **Action Buttons**: Delete buttons hidden for editor role
|
| 240 |
+
- **Access Denied Pages**: Friendly error messages when accessing restricted routes
|
| 241 |
+
|
| 242 |
+
**Protected Routes:**
|
| 243 |
+
- `/ingestion` - Editor, Admin, Owner only
|
| 244 |
+
- `/analytics` - Admin, Owner only
|
| 245 |
+
- `/admin-rules` - Admin, Owner only
|
| 246 |
+
|
| 247 |
+
**Implementation:**
|
| 248 |
+
- Permission utilities in `frontend/lib/permissions.ts`
|
| 249 |
+
- Conditional rendering in components based on role
|
| 250 |
+
- Access denied pages with clear messaging
|
| 251 |
+
|
| 252 |
+
### Using RBAC
|
| 253 |
+
|
| 254 |
+
1. **Change Role**: Use the role dropdown in the header to switch roles
|
| 255 |
+
2. **Verify Permissions**: UI automatically updates to show only permitted features
|
| 256 |
+
3. **API Requests**: Role is automatically sent as `x-user-role` header
|
| 257 |
+
4. **Error Handling**: Access denied pages guide users on required roles
|
| 258 |
+
|
| 259 |
+
**Note**: Role changes are immediate and affect both UI visibility and API permissions. The role persists across page refreshes via localStorage.
|
| 260 |
+
|
| 261 |
+
---
|
| 262 |
+
|
| 263 |
## Installation & Setup
|
| 264 |
|
| 265 |
### Prerequisites
|