10xscale-agentflow-cli 0.2.5__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/10xscale_agentflow_cli.egg-info/PKG-INFO +102 -1
  2. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/10xscale_agentflow_cli.egg-info/SOURCES.txt +8 -1
  3. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/PKG-INFO +102 -1
  4. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/README.md +101 -0
  5. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow.json +4 -1
  6. 10xscale_agentflow_cli-0.2.7/agentflow_cli/src/app/core/auth/authorization.py +90 -0
  7. 10xscale_agentflow_cli-0.2.7/agentflow_cli/src/app/core/auth/permissions.py +150 -0
  8. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/config/graph_config.py +11 -0
  9. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/config/settings.py +68 -0
  10. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/config/setup_logs.py +6 -1
  11. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/config/setup_middleware.py +22 -0
  12. 10xscale_agentflow_cli-0.2.7/agentflow_cli/src/app/core/exceptions/handle_errors.py +354 -0
  13. 10xscale_agentflow_cli-0.2.7/agentflow_cli/src/app/core/middleware/__init__.py +11 -0
  14. 10xscale_agentflow_cli-0.2.7/agentflow_cli/src/app/core/middleware/request_limits.py +73 -0
  15. 10xscale_agentflow_cli-0.2.7/agentflow_cli/src/app/core/middleware/security_headers.py +239 -0
  16. 10xscale_agentflow_cli-0.2.7/agentflow_cli/src/app/core/utils/__init__.py +14 -0
  17. 10xscale_agentflow_cli-0.2.7/agentflow_cli/src/app/core/utils/log_sanitizer.py +195 -0
  18. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/loader.py +91 -33
  19. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/checkpointer/router.py +11 -27
  20. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/checkpointer/services/checkpointer_service.py +3 -2
  21. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/graph/router.py +8 -12
  22. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/graph/services/graph_service.py +15 -5
  23. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/store/router.py +8 -16
  24. 10xscale_agentflow_cli-0.2.7/plan.md +190 -0
  25. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/pyproject.toml +1 -1
  26. 10xscale_agentflow_cli-0.2.5/Task.md +0 -31
  27. 10xscale_agentflow_cli-0.2.5/agentflow_cli/src/app/core/exceptions/handle_errors.py +0 -209
  28. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/10xscale_agentflow_cli.egg-info/dependency_links.txt +0 -0
  29. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/10xscale_agentflow_cli.egg-info/entry_points.txt +0 -0
  30. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/10xscale_agentflow_cli.egg-info/not-zip-safe +0 -0
  31. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/10xscale_agentflow_cli.egg-info/requires.txt +0 -0
  32. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/10xscale_agentflow_cli.egg-info/top_level.txt +0 -0
  33. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/MANIFEST.in +0 -0
  34. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/__init__.py +0 -0
  35. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/__init__.py +0 -0
  36. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/commands/__init__.py +0 -0
  37. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/commands/api.py +0 -0
  38. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/commands/build.py +0 -0
  39. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/commands/init.py +0 -0
  40. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/commands/version.py +0 -0
  41. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/constants.py +0 -0
  42. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/core/__init__.py +0 -0
  43. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/core/config.py +0 -0
  44. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/core/output.py +0 -0
  45. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/core/validation.py +0 -0
  46. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/exceptions.py +0 -0
  47. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/logger.py +0 -0
  48. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/main.py +0 -0
  49. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/templates/__init__.py +0 -0
  50. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/cli/templates/defaults.py +0 -0
  51. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/__init__.py +0 -0
  52. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/__init__.py +0 -0
  53. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/__init__.py +0 -0
  54. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/auth/__init__.py +0 -0
  55. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/auth/auth_backend.py +0 -0
  56. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/auth/base_auth.py +0 -0
  57. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/auth/jwt_auth.py +0 -0
  58. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/config/__init__.py +0 -0
  59. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/config/sentry_config.py +0 -0
  60. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/config/worker_middleware.py +0 -0
  61. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/exceptions/__init__.py +0 -0
  62. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/exceptions/general_exception.py +0 -0
  63. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/exceptions/resources_exceptions.py +0 -0
  64. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/core/exceptions/user_exception.py +0 -0
  65. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/main.py +0 -0
  66. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/__init__.py +0 -0
  67. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/checkpointer/__init__.py +0 -0
  68. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/checkpointer/schemas/__init__.py +0 -0
  69. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/checkpointer/schemas/checkpointer_schemas.py +0 -0
  70. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/checkpointer/services/__init__.py +0 -0
  71. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/graph/__init__.py +0 -0
  72. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/graph/schemas/__init__.py +0 -0
  73. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/graph/schemas/graph_schemas.py +0 -0
  74. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/graph/services/__init__.py +0 -0
  75. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/ping/__init__.py +0 -0
  76. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/ping/router.py +0 -0
  77. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/setup_router.py +0 -0
  78. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/store/__init__.py +0 -0
  79. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/store/schemas/__init__.py +0 -0
  80. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/store/schemas/store_schemas.py +0 -0
  81. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/store/services/__init__.py +0 -0
  82. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/routers/store/services/store_service.py +0 -0
  83. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/tasks/__init__.py +0 -0
  84. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/tasks/user_tasks.py +0 -0
  85. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/__init__.py +0 -0
  86. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/callable_helper.py +0 -0
  87. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/parse_output.py +0 -0
  88. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/response_helper.py +0 -0
  89. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/schemas/__init__.py +0 -0
  90. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/schemas/output_schemas.py +0 -0
  91. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/schemas/user_schemas.py +0 -0
  92. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/snowflake_id_generator.py +0 -0
  93. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/swagger_helper.py +0 -0
  94. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/utils/thread_name_generator.py +0 -0
  95. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/agentflow_cli/src/app/worker.py +0 -0
  96. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/graph/__init__.py +0 -0
  97. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/graph/react.py +0 -0
  98. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/graph/thread_name_generator.py +0 -0
  99. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/scripts/generate_docs.py +0 -0
  100. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/setup.cfg +0 -0
  101. {10xscale_agentflow_cli-0.2.5 → 10xscale_agentflow_cli-0.2.7}/tests/test_utils_parse_and_callable.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: 10xscale-agentflow-cli
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: CLI and API for 10xscale AgentFlow
5
5
  Author-email: 10xscale <contact@10xscale.ai>
6
6
  Maintainer-email: Shudipto Trafder <shudiptotrafder@gmail.com>
@@ -314,6 +314,107 @@ name = generator.generate_name()
314
314
  ```
315
315
 
316
316
  See the [Thread Name Generator Guide](./docs/thread-name-generator.md) for custom implementations.
317
+
318
+ ## Security
319
+
320
+ AgentFlow CLI provides enterprise-grade security features for production deployments.
321
+
322
+ ### Security Features
323
+
324
+ - ✅ **Authentication** - Built-in JWT and custom authentication backends
325
+ - ✅ **Authorization** - Resource-based access control with extensible backends
326
+ - ✅ **Request Limits** - DoS protection with configurable size limits (default 10MB)
327
+ - ✅ **Error Sanitization** - Production-safe error messages preventing information disclosure
328
+ - ✅ **Log Sanitization** - Automatic redaction of sensitive data (tokens, passwords, secrets)
329
+ - ✅ **Security Warnings** - Startup validation for insecure configurations
330
+ - ✅ **HTTPS Ready** - SSL/TLS support with secure headers
331
+
332
+ ### Production Security Checklist
333
+
334
+ Before deploying to production, ensure:
335
+
336
+ ```bash
337
+ # Required: Set production mode
338
+ MODE=production
339
+
340
+ # Required: Strong JWT secret (32+ characters)
341
+ JWT_SECRET_KEY=<generate-with-secrets.token_urlsafe(32)>
342
+
343
+ # Required: Disable debug mode
344
+ IS_DEBUG=false
345
+
346
+ # Required: Specific CORS origins (not *)
347
+ ORIGINS=https://yourdomain.com
348
+
349
+ # Required: Specific allowed hosts (not *)
350
+ ALLOWED_HOST=yourdomain.com
351
+
352
+ # Recommended: Disable API docs
353
+ DOCS_PATH=
354
+ REDOCS_PATH=
355
+
356
+ # Recommended: Configure request size limit
357
+ MAX_REQUEST_SIZE=10485760 # 10MB default
358
+ ```
359
+
360
+ ### Quick Security Setup
361
+
362
+ **1. Enable JWT Authentication:**
363
+ ```json
364
+ {
365
+ "auth": "jwt"
366
+ }
367
+ ```
368
+
369
+ **2. Implement Authorization:**
370
+ ```python
371
+ # auth/rbac_backend.py
372
+ from agentflow_cli.src.app.core.auth.authorization import AuthorizationBackend
373
+
374
+ class RBACAuthorizationBackend(AuthorizationBackend):
375
+ async def authorize(self, user, resource, action, resource_id=None, **context):
376
+ role = user.get("role", "viewer")
377
+ # Implement your authorization logic
378
+ return role == "admin" or (role == "developer" and action == "read")
379
+ ```
380
+
381
+ **3. Configure in agentflow.json:**
382
+ ```json
383
+ {
384
+ "auth": "jwt",
385
+ "authorization": {
386
+ "path": "auth.rbac_backend:RBACAuthorizationBackend"
387
+ }
388
+ }
389
+ ```
390
+
391
+ ### Security Validation
392
+
393
+ AgentFlow automatically validates your configuration and warns about security issues:
394
+
395
+ ```
396
+ ⚠️ SECURITY WARNING: CORS ORIGINS='*' in production.
397
+ Set ORIGINS to specific domains.
398
+
399
+ ⚠️ SECURITY WARNING: DEBUG mode enabled in production!
400
+ Set IS_DEBUG=false
401
+ ```
402
+
403
+ ### Comprehensive Security Guide
404
+
405
+ For detailed security documentation, threat model, best practices, and deployment guidelines, see:
406
+
407
+ 📖 **[SECURITY.md](./SECURITY.md)** - Complete Security Guide
408
+
409
+ Topics covered:
410
+ - Threat model and attack vectors
411
+ - Authentication and authorization patterns
412
+ - Production deployment checklist
413
+ - Docker and Kubernetes security configurations
414
+ - Security testing and monitoring
415
+ - Incident response procedures
416
+ - Vulnerability reporting
417
+
317
418
  ## Deployment
318
419
 
319
420
  See the [Deployment Guide](./docs/deployment.md) for complete deployment instructions.
@@ -1,7 +1,7 @@
1
1
  MANIFEST.in
2
2
  README.md
3
- Task.md
4
3
  agentflow.json
4
+ plan.md
5
5
  pyproject.toml
6
6
  10xscale_agentflow_cli.egg-info/PKG-INFO
7
7
  10xscale_agentflow_cli.egg-info/SOURCES.txt
@@ -35,8 +35,10 @@ agentflow_cli/src/app/worker.py
35
35
  agentflow_cli/src/app/core/__init__.py
36
36
  agentflow_cli/src/app/core/auth/__init__.py
37
37
  agentflow_cli/src/app/core/auth/auth_backend.py
38
+ agentflow_cli/src/app/core/auth/authorization.py
38
39
  agentflow_cli/src/app/core/auth/base_auth.py
39
40
  agentflow_cli/src/app/core/auth/jwt_auth.py
41
+ agentflow_cli/src/app/core/auth/permissions.py
40
42
  agentflow_cli/src/app/core/config/__init__.py
41
43
  agentflow_cli/src/app/core/config/graph_config.py
42
44
  agentflow_cli/src/app/core/config/sentry_config.py
@@ -49,6 +51,11 @@ agentflow_cli/src/app/core/exceptions/general_exception.py
49
51
  agentflow_cli/src/app/core/exceptions/handle_errors.py
50
52
  agentflow_cli/src/app/core/exceptions/resources_exceptions.py
51
53
  agentflow_cli/src/app/core/exceptions/user_exception.py
54
+ agentflow_cli/src/app/core/middleware/__init__.py
55
+ agentflow_cli/src/app/core/middleware/request_limits.py
56
+ agentflow_cli/src/app/core/middleware/security_headers.py
57
+ agentflow_cli/src/app/core/utils/__init__.py
58
+ agentflow_cli/src/app/core/utils/log_sanitizer.py
52
59
  agentflow_cli/src/app/routers/__init__.py
53
60
  agentflow_cli/src/app/routers/setup_router.py
54
61
  agentflow_cli/src/app/routers/checkpointer/__init__.py
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: 10xscale-agentflow-cli
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: CLI and API for 10xscale AgentFlow
5
5
  Author-email: 10xscale <contact@10xscale.ai>
6
6
  Maintainer-email: Shudipto Trafder <shudiptotrafder@gmail.com>
@@ -314,6 +314,107 @@ name = generator.generate_name()
314
314
  ```
315
315
 
316
316
  See the [Thread Name Generator Guide](./docs/thread-name-generator.md) for custom implementations.
317
+
318
+ ## Security
319
+
320
+ AgentFlow CLI provides enterprise-grade security features for production deployments.
321
+
322
+ ### Security Features
323
+
324
+ - ✅ **Authentication** - Built-in JWT and custom authentication backends
325
+ - ✅ **Authorization** - Resource-based access control with extensible backends
326
+ - ✅ **Request Limits** - DoS protection with configurable size limits (default 10MB)
327
+ - ✅ **Error Sanitization** - Production-safe error messages preventing information disclosure
328
+ - ✅ **Log Sanitization** - Automatic redaction of sensitive data (tokens, passwords, secrets)
329
+ - ✅ **Security Warnings** - Startup validation for insecure configurations
330
+ - ✅ **HTTPS Ready** - SSL/TLS support with secure headers
331
+
332
+ ### Production Security Checklist
333
+
334
+ Before deploying to production, ensure:
335
+
336
+ ```bash
337
+ # Required: Set production mode
338
+ MODE=production
339
+
340
+ # Required: Strong JWT secret (32+ characters)
341
+ JWT_SECRET_KEY=<generate-with-secrets.token_urlsafe(32)>
342
+
343
+ # Required: Disable debug mode
344
+ IS_DEBUG=false
345
+
346
+ # Required: Specific CORS origins (not *)
347
+ ORIGINS=https://yourdomain.com
348
+
349
+ # Required: Specific allowed hosts (not *)
350
+ ALLOWED_HOST=yourdomain.com
351
+
352
+ # Recommended: Disable API docs
353
+ DOCS_PATH=
354
+ REDOCS_PATH=
355
+
356
+ # Recommended: Configure request size limit
357
+ MAX_REQUEST_SIZE=10485760 # 10MB default
358
+ ```
359
+
360
+ ### Quick Security Setup
361
+
362
+ **1. Enable JWT Authentication:**
363
+ ```json
364
+ {
365
+ "auth": "jwt"
366
+ }
367
+ ```
368
+
369
+ **2. Implement Authorization:**
370
+ ```python
371
+ # auth/rbac_backend.py
372
+ from agentflow_cli.src.app.core.auth.authorization import AuthorizationBackend
373
+
374
+ class RBACAuthorizationBackend(AuthorizationBackend):
375
+ async def authorize(self, user, resource, action, resource_id=None, **context):
376
+ role = user.get("role", "viewer")
377
+ # Implement your authorization logic
378
+ return role == "admin" or (role == "developer" and action == "read")
379
+ ```
380
+
381
+ **3. Configure in agentflow.json:**
382
+ ```json
383
+ {
384
+ "auth": "jwt",
385
+ "authorization": {
386
+ "path": "auth.rbac_backend:RBACAuthorizationBackend"
387
+ }
388
+ }
389
+ ```
390
+
391
+ ### Security Validation
392
+
393
+ AgentFlow automatically validates your configuration and warns about security issues:
394
+
395
+ ```
396
+ ⚠️ SECURITY WARNING: CORS ORIGINS='*' in production.
397
+ Set ORIGINS to specific domains.
398
+
399
+ ⚠️ SECURITY WARNING: DEBUG mode enabled in production!
400
+ Set IS_DEBUG=false
401
+ ```
402
+
403
+ ### Comprehensive Security Guide
404
+
405
+ For detailed security documentation, threat model, best practices, and deployment guidelines, see:
406
+
407
+ 📖 **[SECURITY.md](./SECURITY.md)** - Complete Security Guide
408
+
409
+ Topics covered:
410
+ - Threat model and attack vectors
411
+ - Authentication and authorization patterns
412
+ - Production deployment checklist
413
+ - Docker and Kubernetes security configurations
414
+ - Security testing and monitoring
415
+ - Incident response procedures
416
+ - Vulnerability reporting
417
+
317
418
  ## Deployment
318
419
 
319
420
  See the [Deployment Guide](./docs/deployment.md) for complete deployment instructions.
@@ -268,6 +268,107 @@ name = generator.generate_name()
268
268
  ```
269
269
 
270
270
  See the [Thread Name Generator Guide](./docs/thread-name-generator.md) for custom implementations.
271
+
272
+ ## Security
273
+
274
+ AgentFlow CLI provides enterprise-grade security features for production deployments.
275
+
276
+ ### Security Features
277
+
278
+ - ✅ **Authentication** - Built-in JWT and custom authentication backends
279
+ - ✅ **Authorization** - Resource-based access control with extensible backends
280
+ - ✅ **Request Limits** - DoS protection with configurable size limits (default 10MB)
281
+ - ✅ **Error Sanitization** - Production-safe error messages preventing information disclosure
282
+ - ✅ **Log Sanitization** - Automatic redaction of sensitive data (tokens, passwords, secrets)
283
+ - ✅ **Security Warnings** - Startup validation for insecure configurations
284
+ - ✅ **HTTPS Ready** - SSL/TLS support with secure headers
285
+
286
+ ### Production Security Checklist
287
+
288
+ Before deploying to production, ensure:
289
+
290
+ ```bash
291
+ # Required: Set production mode
292
+ MODE=production
293
+
294
+ # Required: Strong JWT secret (32+ characters)
295
+ JWT_SECRET_KEY=<generate-with-secrets.token_urlsafe(32)>
296
+
297
+ # Required: Disable debug mode
298
+ IS_DEBUG=false
299
+
300
+ # Required: Specific CORS origins (not *)
301
+ ORIGINS=https://yourdomain.com
302
+
303
+ # Required: Specific allowed hosts (not *)
304
+ ALLOWED_HOST=yourdomain.com
305
+
306
+ # Recommended: Disable API docs
307
+ DOCS_PATH=
308
+ REDOCS_PATH=
309
+
310
+ # Recommended: Configure request size limit
311
+ MAX_REQUEST_SIZE=10485760 # 10MB default
312
+ ```
313
+
314
+ ### Quick Security Setup
315
+
316
+ **1. Enable JWT Authentication:**
317
+ ```json
318
+ {
319
+ "auth": "jwt"
320
+ }
321
+ ```
322
+
323
+ **2. Implement Authorization:**
324
+ ```python
325
+ # auth/rbac_backend.py
326
+ from agentflow_cli.src.app.core.auth.authorization import AuthorizationBackend
327
+
328
+ class RBACAuthorizationBackend(AuthorizationBackend):
329
+ async def authorize(self, user, resource, action, resource_id=None, **context):
330
+ role = user.get("role", "viewer")
331
+ # Implement your authorization logic
332
+ return role == "admin" or (role == "developer" and action == "read")
333
+ ```
334
+
335
+ **3. Configure in agentflow.json:**
336
+ ```json
337
+ {
338
+ "auth": "jwt",
339
+ "authorization": {
340
+ "path": "auth.rbac_backend:RBACAuthorizationBackend"
341
+ }
342
+ }
343
+ ```
344
+
345
+ ### Security Validation
346
+
347
+ AgentFlow automatically validates your configuration and warns about security issues:
348
+
349
+ ```
350
+ ⚠️ SECURITY WARNING: CORS ORIGINS='*' in production.
351
+ Set ORIGINS to specific domains.
352
+
353
+ ⚠️ SECURITY WARNING: DEBUG mode enabled in production!
354
+ Set IS_DEBUG=false
355
+ ```
356
+
357
+ ### Comprehensive Security Guide
358
+
359
+ For detailed security documentation, threat model, best practices, and deployment guidelines, see:
360
+
361
+ 📖 **[SECURITY.md](./SECURITY.md)** - Complete Security Guide
362
+
363
+ Topics covered:
364
+ - Threat model and attack vectors
365
+ - Authentication and authorization patterns
366
+ - Production deployment checklist
367
+ - Docker and Kubernetes security configurations
368
+ - Security testing and monitoring
369
+ - Incident response procedures
370
+ - Vulnerability reporting
371
+
271
372
  ## Deployment
272
373
 
273
374
  See the [Deployment Guide](./docs/deployment.md) for complete deployment instructions.
@@ -2,5 +2,8 @@
2
2
  "agent": "graph.react:app",
3
3
  "thread_name_generator": "graph.thread_name_generator:MyNameGenerator",
4
4
  "env": ".env",
5
- "auth": null
5
+ "auth": {
6
+ "path": "graph.custom_auth:CustomAuth",
7
+ "method": "custom"
8
+ }
6
9
  }
@@ -0,0 +1,90 @@
1
+ """
2
+ Authorization backend system for AgentFlow CLI.
3
+
4
+ This module provides an authorization interface that developers can implement
5
+ to add resource-level access control to their AgentFlow applications.
6
+ """
7
+
8
+ from abc import ABC, abstractmethod
9
+ from typing import Any
10
+
11
+
12
+ class AuthorizationBackend(ABC):
13
+ """
14
+ Abstract base class for authorization backends.
15
+
16
+ Developers should implement this class to define custom authorization logic
17
+ for their AgentFlow applications. The authorize method is called before
18
+ any resource operation to check if the user has permission.
19
+
20
+ Example:
21
+ class MyAuthorizationBackend(AuthorizationBackend):
22
+ async def authorize(self, user, resource, action, resource_id=None, **context):
23
+ # Check if user has permission
24
+ if user.get("role") == "admin":
25
+ return True
26
+ # Add custom logic here
27
+ return False
28
+ """
29
+
30
+ @abstractmethod
31
+ async def authorize(
32
+ self,
33
+ user: dict[str, Any],
34
+ resource: str,
35
+ action: str,
36
+ resource_id: str | None = None,
37
+ **context: Any,
38
+ ) -> bool:
39
+ """
40
+ Check if user can perform action on resource.
41
+
42
+ Args:
43
+ user: User information dictionary containing at least 'user_id'
44
+ resource: Resource type (e.g., 'graph', 'checkpointer', 'store')
45
+ action: Action to perform (e.g., 'invoke', 'stream', 'read', 'write', 'delete')
46
+ resource_id: Optional specific resource identifier (e.g., thread_id, namespace)
47
+ **context: Additional context for authorization decision
48
+
49
+ Returns:
50
+ bool: True if authorized, False otherwise
51
+
52
+ Raises:
53
+ Exception: Can raise exceptions for auth failures or errors
54
+ """
55
+
56
+
57
+ class DefaultAuthorizationBackend(AuthorizationBackend):
58
+ """
59
+ Default authorization backend that allows all authenticated users.
60
+
61
+ This implementation performs basic authentication check (user has user_id)
62
+ but allows all operations. Use this as a starting point or for development.
63
+
64
+ For production use, implement a custom AuthorizationBackend with proper
65
+ access control logic based on your application's requirements.
66
+ """
67
+
68
+ async def authorize(
69
+ self,
70
+ user: dict[str, Any],
71
+ resource: str,
72
+ action: str,
73
+ resource_id: str | None = None,
74
+ **context: Any,
75
+ ) -> bool:
76
+ """
77
+ Allow all authenticated users to perform any action.
78
+
79
+ Args:
80
+ user: User information dictionary
81
+ resource: Resource type (not used in default implementation)
82
+ action: Action to perform (not used in default implementation)
83
+ resource_id: Optional resource identifier (not used in default implementation)
84
+ **context: Additional context (not used in default implementation)
85
+
86
+ Returns:
87
+ bool: True if user has 'user_id', False otherwise
88
+ """
89
+ # Only check if user is authenticated (has user_id)
90
+ return bool(user.get("user_id"))
@@ -0,0 +1,150 @@
1
+ """
2
+ Unified authentication and authorization dependency for FastAPI endpoints.
3
+
4
+ This module provides a reusable dependency that combines authentication and
5
+ authorization checks, reducing code duplication across routers.
6
+ """
7
+
8
+ from collections.abc import Callable
9
+ from typing import Any
10
+
11
+ from fastapi import Depends, HTTPException, Request, Response
12
+ from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
13
+ from injectq.integrations import InjectAPI
14
+
15
+ from agentflow_cli.src.app.core import logger
16
+ from agentflow_cli.src.app.core.auth.auth_backend import BaseAuth
17
+ from agentflow_cli.src.app.core.auth.authorization import AuthorizationBackend
18
+ from agentflow_cli.src.app.core.config.graph_config import GraphConfig
19
+ from agentflow_cli.src.app.core.utils.log_sanitizer import sanitize_for_logging
20
+
21
+
22
+ class RequirePermission:
23
+ """
24
+ FastAPI dependency that combines authentication and authorization.
25
+
26
+ This class-based dependency verifies user authentication and checks
27
+ authorization in a single step, reducing boilerplate code in endpoints.
28
+
29
+ Usage:
30
+ @router.post("/v1/resource")
31
+ async def endpoint(
32
+ user: dict = Depends(RequirePermission("resource", "action"))
33
+ ):
34
+ # User is authenticated and authorized
35
+ pass
36
+
37
+ Args:
38
+ resource: Resource type being accessed (e.g., "graph", "checkpointer", "store")
39
+ action: Action being performed (e.g., "invoke", "read", "write", "delete")
40
+ extract_resource_id: Optional function to extract resource_id from request
41
+ """
42
+
43
+ def __init__(
44
+ self,
45
+ resource: str,
46
+ action: str,
47
+ extract_resource_id: Callable[[Request], str | None] | None = None,
48
+ ):
49
+ """
50
+ Initialize the permission requirement.
51
+
52
+ Args:
53
+ resource: Resource type (graph, checkpointer, store)
54
+ action: Action type (invoke, stream, read, write, delete, etc.)
55
+ extract_resource_id: Optional callable that extracts resource_id from request
56
+ """
57
+ self.resource = resource
58
+ self.action = action
59
+ self.extract_resource_id_fn = extract_resource_id
60
+
61
+ async def __call__(
62
+ self,
63
+ request: Request,
64
+ response: Response,
65
+ credential: HTTPAuthorizationCredentials = Depends(
66
+ HTTPBearer(auto_error=False),
67
+ ),
68
+ config: GraphConfig = InjectAPI(GraphConfig),
69
+ auth_backend: BaseAuth = InjectAPI(BaseAuth),
70
+ authz: AuthorizationBackend = InjectAPI(AuthorizationBackend),
71
+ ) -> dict[str, Any]:
72
+ """
73
+ Verify authentication and authorization.
74
+
75
+ Returns:
76
+ dict: User information if authenticated and authorized
77
+
78
+ Raises:
79
+ HTTPException: 403 if authorization fails
80
+ """
81
+ # Step 1: Authentication (reusing verify_current_user logic)
82
+ user = {}
83
+ backend = config.auth_config()
84
+ if not backend:
85
+ user = {}
86
+ elif not auth_backend:
87
+ logger.error("Auth backend is not configured")
88
+ user = {}
89
+ else:
90
+ user_result = auth_backend.authenticate(
91
+ request,
92
+ response,
93
+ credential,
94
+ )
95
+ if user_result and "user_id" not in user_result:
96
+ logger.error("Authentication failed: 'user_id' not found in user info")
97
+ user = user_result or {}
98
+
99
+ # Step 2: Extract resource_id if available
100
+ resource_id = None
101
+ if self.extract_resource_id_fn:
102
+ resource_id = self.extract_resource_id_fn(request)
103
+ else:
104
+ resource_id = self._extract_resource_id_from_path(request)
105
+
106
+ # Step 3: Authorization
107
+ if not await authz.authorize(
108
+ user,
109
+ self.resource,
110
+ self.action,
111
+ resource_id=resource_id,
112
+ ):
113
+ logger.warning(
114
+ f"Authorization failed for user {user.get('user_id')} "
115
+ f"on {self.resource}:{self.action}"
116
+ )
117
+ raise HTTPException(
118
+ status_code=403,
119
+ detail=f"Not authorized to {self.action} {self.resource}",
120
+ )
121
+
122
+ # Log successful auth/authz (with sanitized user info)
123
+ logger.debug(
124
+ f"Auth/Authz success for {self.resource}:{self.action}, "
125
+ f"user: {sanitize_for_logging(user)}"
126
+ )
127
+
128
+ return user
129
+
130
+ def _extract_resource_id_from_path(self, request: Request) -> str | None:
131
+ """
132
+ Extract resource ID from request path parameters.
133
+
134
+ Looks for common patterns like thread_id, memory_id in path params.
135
+
136
+ Args:
137
+ request: FastAPI request object
138
+
139
+ Returns:
140
+ Resource ID as string, or None if not found
141
+ """
142
+ # Check path parameters
143
+ path_params = request.path_params
144
+
145
+ # Common resource ID patterns
146
+ for param_name in ["thread_id", "memory_id", "namespace"]:
147
+ if param_name in path_params:
148
+ return str(path_params[param_name])
149
+
150
+ return None
@@ -43,6 +43,17 @@ class GraphConfig:
43
43
  def thread_name_generator_path(self) -> str | None:
44
44
  return self.data.get("thread_name_generator", None)
45
45
 
46
+ @property
47
+ def authorization_path(self) -> str | None:
48
+ """
49
+ Get the authorization backend path from configuration.
50
+
51
+ Returns:
52
+ str | None: Path to authorization backend module in format 'module:attribute',
53
+ or None if not configured
54
+ """
55
+ return self.data.get("authorization", None)
56
+
46
57
  def auth_config(self) -> dict | None:
47
58
  res = self.data.get("auth", None)
48
59
  if not res: