Spaces:
Sleeping
Sleeping
Commit
Β·
59466bb
1
Parent(s):
484cae8
update the readme file
Browse files- README.md +32 -1
- backend/README.md +30 -0
README.md
CHANGED
|
@@ -222,6 +222,15 @@ PERMISSIONS = {
|
|
| 222 |
- `/rag/delete*` - Requires `admin` or `owner` role
|
| 223 |
- `/analytics/*` - All roles can view (viewer, editor, admin, owner)
|
| 224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
**Example Request:**
|
| 226 |
```bash
|
| 227 |
curl -X POST "http://localhost:8000/admin/rules" \
|
|
@@ -231,7 +240,10 @@ curl -X POST "http://localhost:8000/admin/rules" \
|
|
| 231 |
-d '{"rule": "Do not share passwords"}'
|
| 232 |
```
|
| 233 |
|
| 234 |
-
If the role lacks permission, the API returns `403 Forbidden` with a descriptive error message
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
### Frontend RBAC
|
| 237 |
|
|
@@ -575,6 +587,9 @@ IntegraChat includes three powerful visualization components that provide real-t
|
|
| 575 |
Most endpoints require:
|
| 576 |
- `x-tenant-id`: Tenant identifier for multi-tenant isolation
|
| 577 |
- `x-user-role`: Caller role for RBAC enforcement (`viewer`, `editor`, `admin`, or `owner`)
|
|
|
|
|
|
|
|
|
|
| 578 |
- `Content-Type: application/json`: For POST requests with JSON payloads
|
| 579 |
|
| 580 |
### Example Request
|
|
@@ -754,6 +769,8 @@ See `SUPABASE_SETUP.md` and `SUPABASE_MIGRATION_COMPLETE.md` for detailed instru
|
|
| 754 |
- Check file size limits (default may be 10MB)
|
| 755 |
- Verify file format is supported (PDF, DOCX, TXT, MD)
|
| 756 |
- Ensure tenant_id is provided in request
|
|
|
|
|
|
|
| 757 |
- Check backend logs for specific error messages
|
| 758 |
- Verify PostgreSQL connection for RAG storage
|
| 759 |
|
|
@@ -871,6 +888,20 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
| 871 |
|
| 872 |
## Recent Enhancements
|
| 873 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 874 |
### Admin Rules System (Latest)
|
| 875 |
- **File Upload Support**: Upload rules from TXT, PDF, DOC, DOCX files with drag-and-drop interface
|
| 876 |
- **LLM Enhancement**: Automatic rule enhancement identifies edge cases, improves regex patterns, and suggests severity levels
|
|
|
|
| 222 |
- `/rag/delete*` - Requires `admin` or `owner` role
|
| 223 |
- `/analytics/*` - All roles can view (viewer, editor, admin, owner)
|
| 224 |
|
| 225 |
+
**Role Propagation:**
|
| 226 |
+
The user role is automatically propagated through the entire request pipeline:
|
| 227 |
+
1. Frontend sends `x-user-role` header
|
| 228 |
+
2. Backend API route receives and validates role
|
| 229 |
+
3. Role is passed to service layer (`process_ingestion()`, etc.)
|
| 230 |
+
4. Service layer passes role to MCP clients
|
| 231 |
+
5. MCP clients include role in payload to MCP server
|
| 232 |
+
6. MCP server extracts role and enforces permissions
|
| 233 |
+
|
| 234 |
**Example Request:**
|
| 235 |
```bash
|
| 236 |
curl -X POST "http://localhost:8000/admin/rules" \
|
|
|
|
| 240 |
-d '{"rule": "Do not share passwords"}'
|
| 241 |
```
|
| 242 |
|
| 243 |
+
If the role lacks permission, the API returns `403 Forbidden` with a descriptive error message that includes:
|
| 244 |
+
- Which role was used
|
| 245 |
+
- Which roles are allowed for the action
|
| 246 |
+
- Instructions to change role in the UI
|
| 247 |
|
| 248 |
### Frontend RBAC
|
| 249 |
|
|
|
|
| 587 |
Most endpoints require:
|
| 588 |
- `x-tenant-id`: Tenant identifier for multi-tenant isolation
|
| 589 |
- `x-user-role`: Caller role for RBAC enforcement (`viewer`, `editor`, `admin`, or `owner`)
|
| 590 |
+
- **Important**: Role must be passed through the entire pipeline (UI β API β RAG Client β MCP Server)
|
| 591 |
+
- Role is automatically propagated from the frontend to backend API, then to RAG client, and finally to MCP server for permission checks
|
| 592 |
+
- If ingestion fails with permission errors, verify the role is set correctly in the UI and check backend logs for role propagation debug messages
|
| 593 |
- `Content-Type: application/json`: For POST requests with JSON payloads
|
| 594 |
|
| 595 |
### Example Request
|
|
|
|
| 769 |
- Check file size limits (default may be 10MB)
|
| 770 |
- Verify file format is supported (PDF, DOCX, TXT, MD)
|
| 771 |
- Ensure tenant_id is provided in request
|
| 772 |
+
- **Check user role**: Ingestion requires `editor`, `admin`, or `owner` role. If you see "Permission Denied (403)", change your role in the UI dropdown (top right) from "viewer" to "editor", "admin", or "owner"
|
| 773 |
+
- Verify `x-user-role` header is being sent correctly (check backend logs for debug messages)
|
| 774 |
- Check backend logs for specific error messages
|
| 775 |
- Verify PostgreSQL connection for RAG storage
|
| 776 |
|
|
|
|
| 888 |
|
| 889 |
## Recent Enhancements
|
| 890 |
|
| 891 |
+
### Role Propagation & Permission Handling (Latest)
|
| 892 |
+
- **Fixed Role Propagation**: User role (`viewer`, `editor`, `admin`, `owner`) is now properly passed through the entire ingestion pipeline:
|
| 893 |
+
- UI sends role in `x-user-role` header
|
| 894 |
+
- Backend API route receives and validates role
|
| 895 |
+
- Role is passed to `process_ingestion()` service
|
| 896 |
+
- RAG client includes role in payload to MCP server
|
| 897 |
+
- MCP server uses role for permission checks
|
| 898 |
+
- **Improved Error Handling**: Permission errors (403 Forbidden) now return clear, actionable error messages:
|
| 899 |
+
- Clear indication when role lacks required permissions
|
| 900 |
+
- Guidance on which roles can perform specific actions
|
| 901 |
+
- Instructions to change role in UI dropdown
|
| 902 |
+
- **Debug Logging**: Added comprehensive debug logging to trace role values through the pipeline for troubleshooting
|
| 903 |
+
- **Admin Question Handling**: Fixed "who is the admin" type questions to use RAG from knowledge base instead of generic LLM responses
|
| 904 |
+
|
| 905 |
### Admin Rules System (Latest)
|
| 906 |
- **File Upload Support**: Upload rules from TXT, PDF, DOC, DOCX files with drag-and-drop interface
|
| 907 |
- **LLM Enhancement**: Automatic rule enhancement identifies edge cases, improves regex patterns, and suggests severity levels
|
backend/README.md
CHANGED
|
@@ -185,6 +185,22 @@ Every tool now returns strict JSON schemas for consistency:
|
|
| 185 |
|
| 186 |
**Schema Definitions**: `backend/api/services/tool_metadata.py` contains `TOOL_OUTPUT_SCHEMAS` with validation functions.
|
| 187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
### UI Enhancements (app.py)
|
| 189 |
- **Knowledge Base Library Tab**:
|
| 190 |
- Statistics cards showing document counts by type
|
|
@@ -347,6 +363,20 @@ Agents that speak the Model Context Protocol should connect to the `integrachat`
|
|
| 347 |
- **Ensure knowledge base content exists**: Questions like "who is the admin" require relevant content in the knowledge base
|
| 348 |
- **Pattern matching**: The tool selector automatically triggers RAG for patterns like "admin", "who is", "what is", but semantic similarity also plays a role
|
| 349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
### Document Deletion Issues
|
| 351 |
- **404 Not Found**: Verify the document_id exists and belongs to the correct tenant
|
| 352 |
- **Tenant ID mismatch**: The system normalizes tenant IDs, but ensure you're using the same tenant_id format as when documents were ingested
|
|
|
|
| 185 |
|
| 186 |
**Schema Definitions**: `backend/api/services/tool_metadata.py` contains `TOOL_OUTPUT_SCHEMAS` with validation functions.
|
| 187 |
|
| 188 |
+
### Role Propagation & Permission Handling
|
| 189 |
+
- **Fixed Role Propagation**: User role is now properly passed from API route β `process_ingestion()` β RAG client β MCP server
|
| 190 |
+
- `rag_client.ingest_with_metadata()` now accepts `user_role` parameter
|
| 191 |
+
- Role is included in payload sent to MCP server: `{"user_role": "owner", ...}`
|
| 192 |
+
- MCP server extracts role from payload via `build_tenant_context()` and uses it for permission checks
|
| 193 |
+
- **Improved Error Handling**:
|
| 194 |
+
- Permission errors (403) return clear messages with actionable guidance
|
| 195 |
+
- Error messages specify which roles are allowed for each action
|
| 196 |
+
- Frontend displays user-friendly error messages with instructions
|
| 197 |
+
- **Debug Logging**: Added debug logging in route handlers and services to trace role values:
|
| 198 |
+
- Logs role received in route handler
|
| 199 |
+
- Logs role passed to process_ingestion
|
| 200 |
+
- Logs role sent to RAG client
|
| 201 |
+
- Logs role received by MCP server
|
| 202 |
+
- **Admin Question Handling**: Fixed admin identity questions to prioritize RAG results from knowledge base
|
| 203 |
+
|
| 204 |
### UI Enhancements (app.py)
|
| 205 |
- **Knowledge Base Library Tab**:
|
| 206 |
- Statistics cards showing document counts by type
|
|
|
|
| 363 |
- **Ensure knowledge base content exists**: Questions like "who is the admin" require relevant content in the knowledge base
|
| 364 |
- **Pattern matching**: The tool selector automatically triggers RAG for patterns like "admin", "who is", "what is", but semantic similarity also plays a role
|
| 365 |
|
| 366 |
+
### Document Ingestion Permission Errors
|
| 367 |
+
- **403 Forbidden**: If you see "Role 'viewer' is not permitted to perform 'ingest_documents'":
|
| 368 |
+
- Change your role in the UI dropdown (top right) from "viewer" to "editor", "admin", or "owner"
|
| 369 |
+
- Verify `x-user-role` header is being sent correctly (check backend logs for `π DEBUG:` messages)
|
| 370 |
+
- Check that role is being propagated through the pipeline: route handler β process_ingestion β RAG client β MCP server
|
| 371 |
+
- Review debug logs to see where role might be getting lost or defaulting to "viewer"
|
| 372 |
+
- **Role Propagation**: The role must flow through:
|
| 373 |
+
1. UI sends `x-user-role` header
|
| 374 |
+
2. Route handler receives it as `x_user_role` parameter
|
| 375 |
+
3. Route handler passes it to `process_ingestion(user_role=...)`
|
| 376 |
+
4. `process_ingestion` passes it to `rag_client.ingest_with_metadata(user_role=...)`
|
| 377 |
+
5. RAG client includes it in payload: `{"user_role": "...", ...}`
|
| 378 |
+
6. MCP server extracts it via `build_tenant_context()` and uses for permission checks
|
| 379 |
+
|
| 380 |
### Document Deletion Issues
|
| 381 |
- **404 Not Found**: Verify the document_id exists and belongs to the correct tenant
|
| 382 |
- **Tenant ID mismatch**: The system normalizes tenant IDs, but ensure you're using the same tenant_id format as when documents were ingested
|